1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/d32usbcsc.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1558 @@
1.4 +// Copyright (c) 2008-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 +// e32\include\d32usbcsc.h
1.18 +// User side class definitions for USB Device support.
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file d32usbcsc.h
1.24 + @publishedPartner
1.25 + @released
1.26 +*/
1.27 +
1.28 +#ifndef __D32USBCSC_H__
1.29 +#define __D32USBCSC_H__
1.30 +
1.31 +#include <e32ver.h>
1.32 +#include <usb.h>
1.33 +#include <d32usbcshared.h>
1.34 +
1.35 +
1.36 +/** This means that SetInterface was called after RealizeInterface had been called.
1.37 + RealizeInterface is meant to signal that all interfaces have been set.
1.38 +*/
1.39 +const TInt KErrUsbAlreadyRealized = -6813; //Changed from -6713 for future compatibility with the d32usbcshared.h file
1.40 +
1.41 +const TInt KErrAlternateSettingChanged = -6814;
1.42 +
1.43 +
1.44 +const TUint KChunkCellSize = 1; //1 32 bit integer
1.45 +const TInt KEpDescPacketSizeOffset = 4;
1.46 +
1.47 +/** The user side enpoint number of Endpoint Zero. */
1.48 +const TInt KEp0Number = 0;
1.49 +
1.50 +/* Used in TUsbcScHdrEndpointRecord to describe the endpoint type
1.51 +*/
1.52 +
1.53 +const TUint8 KUsbScHdrEpDirectionIn=1;
1.54 +const TUint8 KUsbScHdrEpDirectionOut=2;
1.55 +const TUint8 KUsbScHdrEpDirectionBiDir=3;
1.56 +
1.57 +
1.58 +const TUint8 KUsbScHdrEpTypeControl = 0;
1.59 +const TUint8 KUsbScHdrEpTypeIsochronous =1;
1.60 +const TUint8 KUsbScHdrEpTypeBulk = 2;
1.61 +const TUint8 KUsbScHdrEpTypeInterrupt = 3;
1.62 +const TUint8 KUsbScHdrEpTypeUnknown = ~0;
1.63 +/** Used in the the Shared Chunk Header, to represent an endpoint.
1.64 +*/
1.65 +class TUsbcScHdrEndpointRecord
1.66 + {
1.67 +public:
1.68 + inline TUsbcScHdrEndpointRecord(TInt aBufferNo, TUint8 aType);
1.69 + inline TUint Direction() const;
1.70 + inline TUint Type() const;
1.71 +public:
1.72 + TUint8 iBufferNo;
1.73 + TUint8 iType;
1.74 + TUint16 iReserved;
1.75 + };
1.76 +
1.77 +
1.78 +// This is used to hold the geometry of the shared buffers
1.79 +class TUsbcScBufferRecord
1.80 + {
1.81 + friend class DLddUsbcScChannel;
1.82 +
1.83 +public:
1.84 + inline TUint Offset() const;
1.85 + inline TUint Size() const;
1.86 +private:
1.87 + inline void Set(TUint aOffset, TUint aEndOffset);
1.88 + TUint iOffset;
1.89 + TUint iSize;
1.90 + };
1.91 +
1.92 +struct SUsbcScBufferHeader
1.93 + {
1.94 + TInt iHead; // Where the LDD will next write a transfer
1.95 + TInt iTail; // Indicates the fist packet that user side is processing (anything prior is disposable)
1.96 + TInt iBilTail; // This is not used by LDD at all, but just for the BIL's benifit.
1.97 + };
1.98 +
1.99 +
1.100 +struct SUsbcScAlternateSetting
1.101 + {
1.102 + TUint16 iSetting;
1.103 + TUint16 iSequence;
1.104 + };
1.105 +
1.106 +/** Endpoint pair information. This can be used to control pairing of endpoint
1.107 +for classes that require explicit pairing of endpoint, such as ADC.
1.108 +
1.109 +This is currently not used.
1.110 +*/
1.111 +
1.112 +class TEndpointPairInfo
1.113 +{
1.114 +public:
1.115 + TEndpointPairInfo(TUint8 aType=0, TUint16 aPair=0, TUint8 aSpare=0);
1.116 +public:
1.117 + TUint8 iType;
1.118 + TUint8 iSpare;
1.119 + TUint16 iPair;
1.120 +};
1.121 +
1.122 +/**
1.123 +This is the buffer number reserved for use with endpoint zero with the ReadDataNotify and WriteData methods.
1.124 +*/
1.125 +const TInt KUsbcScEndpointZero = -1;
1.126 +
1.127 +/**
1.128 +This flag is reserved in TUsbcscEndpointInfo::iFlags, to indicate that the client driver's client wishes reads to operate in a coupled fashion.
1.129 +This behaviour is not currently supported.
1.130 +*/
1.131 +const TUint KUsbScCoupledRead = 0x1;
1.132 +
1.133 +/**
1.134 +This flag, used in parameter aFlag of WriteData, is used to indicate that a ZLP should be sent.
1.135 +*/
1.136 +const TUint KUsbcScWriteFlagsZlp = 0x0001;
1.137 +
1.138 +
1.139 +// Bit fields used in iFlags of TUsbcScTransferHeader
1.140 +
1.141 +const TUint KUsbcScShortPacket = 0x0001;
1.142 +const TUint KUsbcScStateChange = 0x0004;
1.143 +
1.144 +class TUsbcScTransferHeader
1.145 +{
1.146 +public:
1.147 +#ifdef _DEBUG
1.148 + TUint iHashId;
1.149 + TUint iSequence;
1.150 +#endif
1.151 + TUint iBytes;
1.152 + TUint iFlags;
1.153 + TUint iNext;
1.154 + TUint16 iAltSettingSeq;
1.155 + TInt16 iAltSetting;
1.156 + union
1.157 + {
1.158 + TUint i[1]; // Extends
1.159 + TUint8 b[4]; // Extends
1.160 + } iData;
1.161 +};
1.162 +
1.163 +/** The desired endpoint capabilities used in RDevUsbcScClient::SetInterface().
1.164 +
1.165 +This derived class has additional fields used in the shared chunk USB driver.
1.166 +*/
1.167 +class TUsbcScEndpointInfo: public TUsbcEndpointInfo
1.168 + {
1.169 +public:
1.170 + TUsbcScEndpointInfo(TUint aType=KUsbEpTypeBulk, TUint aDir=KUsbEpDirOut, TInt aInterval=0, TInt aExtra=0,
1.171 + TUint aBufferSize=0, TUint aReadSize=0);
1.172 +
1.173 +
1.174 +public:
1.175 + /** This indicates the requested size of the endpoint buffer and must be at
1.176 + least as large as iReadSize.
1.177 + */
1.178 + TUint iBufferSize;
1.179 +
1.180 + /** This is the amount of data that the LDD reads from the bus before it sets
1.181 + up another read and is normally intended to read many packets.
1.182 + */
1.183 + TUint iReadSize;
1.184 +
1.185 + /** TEndpointPairInfo represents pairing information for isochronous endpoints.
1.186 + Should be zero in other cases. If this specifies paired endpoints then
1.187 + iExtra (in the base class TUsbcEndpointInfo) also needs to be set to the
1.188 + class specific size for this endpoint descriptor (This is here only for future use).
1.189 + */
1.190 + TEndpointPairInfo iPairing;
1.191 +
1.192 + /** The necessary alignment, in bytes, that needs to be applied to the transfer start points
1.193 + of the data. This is only observed on OUT endpoints. Zero can be specified to indicate
1.194 + there are no class side requirements for alignment. The alignment for OUT endpoints is
1.195 + which ever is greater of this field or the USB hardware requirements.
1.196 + */
1.197 + TUint iAlignment;
1.198 +
1.199 + /** Flags to indicate how the endpoint should function. None currently defined,
1.200 + but could be used to allow support for direct read.
1.201 + */
1.202 + TUint iFlags;
1.203 +
1.204 + /** Reserved for future use. */
1.205 + TUint32 iReserved2[2];
1.206 + };
1.207 +
1.208 +/** This must be filled in prior to a call to RDevUsbcClient::SetInterface().
1.209 +*/
1.210 +class TUsbcScInterfaceInfo
1.211 + {
1.212 +public:
1.213 + TUsbcScInterfaceInfo(TInt aClass=0, TInt aSubClass=0, TInt aProtocol=0,
1.214 + TDesC16* aString=NULL, TUint aTotalEndpoints=0);
1.215 +public:
1.216 + /** The class, subclass and protocol that this interface supports. */
1.217 + TUsbcClassInfo iClass;
1.218 + /** The description string for the interface. Used to construct the interface string descriptor. */
1.219 + const TDesC16* iString;
1.220 + /** Total number of endpoints being requested (0-5). Endpoint 0 should not be included in this number. */
1.221 + TUint iTotalEndpointsUsed;
1.222 + /** Desired properties of the endpoints requested.
1.223 + Do NOT include endpoint 0.
1.224 + APIs use endpoint numbers that are offsets into this array.
1.225 + */
1.226 + TUsbcScEndpointInfo iEndpointData[KMaxEndpointsPerClient];
1.227 + /** 32 flag bits used for specifying miscellaneous Interface features.
1.228 + Currently defined are:
1.229 + - KUsbcInterfaceInfo_NoEp0RequestsPlease = 0x00000001
1.230 + */
1.231 + TUint32 iFeatureWord;
1.232 + };
1.233 +
1.234 +/** Package buffer for a TUsbcInterfaceInfo object.
1.235 +
1.236 + @see TUsbcInterfaceInfo
1.237 +*/
1.238 +typedef TPckgBuf<TUsbcScInterfaceInfo> TUsbcScInterfaceInfoBuf;
1.239 +
1.240 +struct TUsbcScChunkHdrOffs
1.241 + {
1.242 + TUint iBuffers;
1.243 + TUint iAltSettings;
1.244 + };
1.245 +
1.246 +
1.247 +class TUsbcScChunkBuffersHeader // Not instantiable
1.248 + {
1.249 + friend class DLddUsbcScChannel;
1.250 + friend class TRealizeInfo;
1.251 +
1.252 +public:
1.253 + inline TUsbcScBufferRecord* Ep0Out() const;
1.254 + inline TUsbcScBufferRecord* Ep0In() const;
1.255 + inline TUsbcScBufferRecord* Buffers(TInt aBuffer) const;
1.256 + inline TInt NumberOfBuffers() const;
1.257 +
1.258 +private:
1.259 + TUsbcScChunkBuffersHeader();
1.260 +private:
1.261 + TInt iRecordSize;
1.262 + TInt iNumOfBufs;
1.263 + TUint8 iBufferOffset[8]; // Extends
1.264 + };
1.265 +
1.266 +struct TUsbcScChunkAltSettingHeader // Not instantiable
1.267 + {
1.268 + TInt iEpRecordSize;
1.269 + TInt iNumOfAltSettings;
1.270 + TUint iAltTableOffset[1]; // Extends
1.271 + };
1.272 +
1.273 +class TEndpointBuffer;
1.274 +
1.275 +
1.276 +/** The user side handle to the USB client driver.
1.277 +*/
1.278 +class RDevUsbcScClient : public RBusLogicalChannel
1.279 + {
1.280 +public:
1.281 + /** @internalComponent */
1.282 + enum TVer
1.283 + {
1.284 + EMajorVersionNumber = 0,
1.285 + EMinorVersionNumber = 1,
1.286 + EBuildVersionNumber = KE32BuildVersionNumber
1.287 + };
1.288 +
1.289 +// Bit pattern. s = Request/Control. c = Cancel, m = mode bits, B = Buffer number, R = request number.
1.290 +// scmm mmmm | mmmm mmmm | mmBB BBBB |RRRR RRRR
1.291 +
1.292 + enum TRequest
1.293 + {
1.294 + ERequestWriteData = 1,
1.295 + ERequestReadDataNotify = 2,
1.296 + ERequestAlternateDeviceStatusNotify = 3,
1.297 + ERequestReEnumerate = 4,
1.298 + ERequestEndpointStatusNotify = 5,
1.299 + ERequestOtgFeaturesNotify = 6,
1.300 + ERequestMaxRequests, // 7
1.301 +
1.302 + ERequestCancel = 0x40000000,
1.303 +
1.304 + ERequestWriteDataCancel = ERequestWriteData | ERequestCancel,
1.305 + ERequestReadDataNotifyCancel = ERequestReadDataNotify | ERequestCancel,
1.306 + ERequestAlternateDeviceStatusNotifyCancel = ERequestAlternateDeviceStatusNotify | ERequestCancel,
1.307 + ERequestReEnumerateCancel = ERequestReEnumerate | ERequestCancel,
1.308 + ERequestEndpointStatusNotifyCancel = ERequestEndpointStatusNotify | ERequestCancel,
1.309 + ERequestOtgFeaturesNotifyCancel = ERequestOtgFeaturesNotify | ERequestCancel
1.310 + };
1.311 +
1.312 + enum TControl
1.313 + {
1.314 + // Changing the order of these enums will break BC.
1.315 + EControlEndpointZeroRequestError, // 00
1.316 + EControlEndpointCaps,
1.317 + EControlDeviceCaps,
1.318 + EControlGetAlternateSetting,
1.319 + EControlDeviceStatus,
1.320 + EControlEndpointStatus,
1.321 + EControlSetInterface,
1.322 + EControlReleaseInterface,
1.323 + EControlSendEp0StatusPacket,
1.324 + EControlHaltEndpoint, // 09
1.325 + //
1.326 + EControlClearHaltEndpoint, // 10
1.327 + EControlSetDeviceControl,
1.328 + EControlReleaseDeviceControl,
1.329 + EControlEndpointZeroMaxPacketSizes,
1.330 + EControlSetEndpointZeroMaxPacketSize,
1.331 + EControlGetDeviceDescriptor,
1.332 + EControlSetDeviceDescriptor,
1.333 + EControlGetDeviceDescriptorSize,
1.334 + EControlGetConfigurationDescriptor,
1.335 + EControlSetConfigurationDescriptor, // 19
1.336 + //
1.337 + EControlGetConfigurationDescriptorSize, // 20
1.338 + EControlGetInterfaceDescriptor,
1.339 + EControlSetInterfaceDescriptor,
1.340 + EControlGetInterfaceDescriptorSize,
1.341 + EControlGetEndpointDescriptor,
1.342 + EControlSetEndpointDescriptor,
1.343 + EControlGetEndpointDescriptorSize,
1.344 + EControlGetCSInterfaceDescriptor,
1.345 + EControlSetCSInterfaceDescriptor,
1.346 + EControlGetCSInterfaceDescriptorSize, // 29
1.347 + //
1.348 + EControlGetCSEndpointDescriptor, // 30
1.349 + EControlSetCSEndpointDescriptor,
1.350 + EControlGetCSEndpointDescriptorSize,
1.351 + EControlSignalRemoteWakeup,
1.352 + EControlGetStringDescriptorLangId,
1.353 + EControlSetStringDescriptorLangId,
1.354 + EControlGetManufacturerStringDescriptor,
1.355 + EControlSetManufacturerStringDescriptor,
1.356 + EControlRemoveManufacturerStringDescriptor,
1.357 + EControlGetProductStringDescriptor, // 39
1.358 + //
1.359 + EControlSetProductStringDescriptor, // 40
1.360 + EControlRemoveProductStringDescriptor,
1.361 + EControlGetSerialNumberStringDescriptor,
1.362 + EControlSetSerialNumberStringDescriptor,
1.363 + EControlRemoveSerialNumberStringDescriptor,
1.364 + EControlGetConfigurationStringDescriptor,
1.365 + EControlSetConfigurationStringDescriptor,
1.366 + EControlRemoveConfigurationStringDescriptor,
1.367 + EControlDeviceDisconnectFromHost,
1.368 + EControlDeviceConnectToHost, // 49
1.369 + //
1.370 + EControlDevicePowerUpUdc, // 50
1.371 + EControlDumpRegisters,
1.372 + EControlAllocateEndpointResource,
1.373 + EControlDeAllocateEndpointResource,
1.374 + EControlQueryEndpointResourceUse,
1.375 + EControlGetEndpointZeroMaxPacketSize,
1.376 + EControlGetDeviceQualifierDescriptor,
1.377 + EControlSetDeviceQualifierDescriptor,
1.378 + EControlGetOtherSpeedConfigurationDescriptor,
1.379 + EControlSetOtherSpeedConfigurationDescriptor, // 59
1.380 + //
1.381 + EControlCurrentlyUsingHighSpeed, // 60
1.382 + EControlSetStringDescriptor,
1.383 + EControlGetStringDescriptor,
1.384 + EControlRemoveStringDescriptor,
1.385 + EControlSetOtgDescriptor,
1.386 + EControlGetOtgDescriptor,
1.387 + EControlGetOtgFeatures,
1.388 + EControlRealizeInterface,
1.389 + EControlStartNextInAlternateSetting
1.390 + };
1.391 +
1.392 +
1.393 + // const static TUint KFieldIdPos = 0;
1.394 + const static TUint KFieldIdMask = 0xFF;
1.395 + const static TUint KFieldBuffPos = 8;
1.396 + const static TUint KFieldBuffMask = 0x3F;
1.397 + const static TUint KFieldFlagsPos = 14;
1.398 + const static TUint KFieldFlagsMask = 0xFFFF;
1.399 +
1.400 +
1.401 +public:
1.402 +
1.403 +#ifndef __KERNEL_MODE__
1.404 +
1.405 + /** Opens a channel.
1.406 +
1.407 + @param aUnit This should be 0 (zero).
1.408 +
1.409 + @return KErrNone if successful.
1.410 + */
1.411 + inline TInt Open(TInt aUnit);
1.412 +
1.413 + inline TVersion VersionRequired() const;
1.414 +
1.415 + /** Stalls ep0 to signal command fault to the host.
1.416 +
1.417 + @return KErrNone if successful.
1.418 + */
1.419 + inline TInt EndpointZeroRequestError();
1.420 +
1.421 + /** Retrieves the capabilities of all the endpoints on the device.
1.422 +
1.423 + Suggested use is as follows:
1.424 +
1.425 + @code
1.426 + TUsbcEndpointData data[KUsbcMaxEndpoints];
1.427 + TPtr8 dataPtr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
1.428 + ret = usbPort.EndpointCaps(dataPtr);
1.429 + @endcode
1.430 +
1.431 + @param aEpCapsBuf A descriptor encapsulating an array of TUsbcEndpointData.
1.432 +
1.433 + @return KErrNone if successful.
1.434 + */
1.435 + inline TInt EndpointCaps(TDes8& aEpCapsBuf);
1.436 +
1.437 + /** Retrieves the capabilities of the USB device.
1.438 +
1.439 + @see TUsbDeviceCaps
1.440 +
1.441 + @param aDevCapsBuf A TUsbDeviceCaps object.
1.442 +
1.443 + @return KErrNone if successful.
1.444 + */
1.445 + inline TInt DeviceCaps(TUsbDeviceCaps& aDevCapsBuf);
1.446 +
1.447 + /** Copies the current alternate setting for this interface into aInterfaceNumber
1.448 + For USB Interfaces whose main interface is active, this will be 0 (zero).
1.449 +
1.450 + @param aInterfaceNumber Current alternate setting for this interface is copied into this.
1.451 +
1.452 + @return KErrNone if successful.
1.453 + */
1.454 + inline TInt GetAlternateSetting(TInt& aInterfaceNumber);
1.455 +
1.456 + /** Copies the current device status into aDeviceStatus.
1.457 +
1.458 + @param aDeviceStatus Current device status is copied into this.
1.459 +
1.460 + @return KErrNone if successful
1.461 + */
1.462 + inline TInt DeviceStatus(TUsbcDeviceState& aDeviceStatus);
1.463 +
1.464 + /** Copies the current endpoint status into aEndpointStatus.
1.465 +
1.466 + @param aEndpoint Endpoint number valid for the current alternate setting.
1.467 + @param aEndpointStatus The current endpoint status, might be stalled, not stalled or unknown.
1.468 +
1.469 + @return KErrNone if successful.
1.470 + */
1.471 + inline TInt EndpointStatus(TInt aEndpoint, TEndpointState& aEndpointStatus);
1.472 +
1.473 +
1.474 + /** Requests that a zero length status packet be sent to the host in response
1.475 + to a class or vendor specific ep0 SETUP packet.
1.476 +
1.477 + @return KErrNone if successful.
1.478 + */
1.479 + inline TInt SendEp0StatusPacket();
1.480 +
1.481 + /** Stalls endpoint aEndpoint, usually to indicate an error condition with a previous command.
1.482 + The host will normally send a SET_FEATURE command on ep0 to acknowledge and clear the stall.
1.483 +
1.484 + @return KErrNone if successful.
1.485 + */
1.486 + inline TInt HaltEndpoint(TInt aEndpoint);
1.487 +
1.488 + /** Clears the stall condition on endpoint aEndpoint. This is inluded for symmetry and test purposes.
1.489 +
1.490 + @return KErrNone if successful.
1.491 + */
1.492 + inline TInt ClearHaltEndpoint(TInt aEndpoint);
1.493 +
1.494 + /** Requests that device control be allocated to this channel.
1.495 +
1.496 + @return KErrNone if successful.
1.497 + */
1.498 + inline TInt SetDeviceControl();
1.499 +
1.500 + /** Relinquishes device control previously allocated to this channel.
1.501 +
1.502 + @return KErrNone if successful.
1.503 + */
1.504 + inline TInt ReleaseDeviceControl();
1.505 +
1.506 + /** Returns a bitmap of available ep0 maximum packet sizes.
1.507 +
1.508 + @return bitmap of available ep0 maximum packet sizes.
1.509 + */
1.510 + inline TUint EndpointZeroMaxPacketSizes();
1.511 +
1.512 + /** Requests that a maximum packet size of aMaxPacketSize be set on ep0.
1.513 +
1.514 + @param aMaxPacketSize The maximum packet size.
1.515 +
1.516 + @return KErrNone if successful.
1.517 + */
1.518 + inline TInt SetEndpointZeroMaxPacketSize(TInt aMaxPacketSize);
1.519 +
1.520 + /** Queries the current maximum packet size on ep0.
1.521 +
1.522 + @return The currently set maximum packet size on ep0.
1.523 + */
1.524 + inline TInt GetEndpointZeroMaxPacketSize();
1.525 +
1.526 + /** Copies the current device descriptor into aDeviceDescriptor.
1.527 +
1.528 + @param aDeviceDescriptor Receives the current device descriptor.
1.529 +
1.530 + @return KErrNone if successful.
1.531 + */
1.532 + inline TInt GetDeviceDescriptor(TDes8& aDeviceDescriptor);
1.533 +
1.534 + /** Sets the contents of aDeviceDescriptor to be the current device descriptor.
1.535 +
1.536 + @param aDeviceDescriptor Contains the device descriptor.
1.537 +
1.538 + @return KErrNone if successful.
1.539 + */
1.540 + inline TInt SetDeviceDescriptor(const TDesC8& aDeviceDescriptor);
1.541 +
1.542 + /** Gets the size of the current device descriptor. This is unlikely to be anything other than 9.
1.543 +
1.544 + @param aSize Receives the size of the current device descriptor.
1.545 +
1.546 + @return KErrNone if successful.
1.547 + */
1.548 + inline TInt GetDeviceDescriptorSize(TInt& aSize);
1.549 +
1.550 + /** Copies the current configuration descriptor into aConfigurationDescriptor.
1.551 +
1.552 + @param aConfigurationDescriptor Receives the current configuration descriptor.
1.553 +
1.554 + @return KErrNone if successful.
1.555 + */
1.556 + inline TInt GetConfigurationDescriptor(TDes8& aConfigurationDescriptor);
1.557 +
1.558 + /** Sets the contents of aConfigurationDescriptor to be the current configuration descriptor.
1.559 +
1.560 + @param aConfigurationDescriptor Contains the configuration descriptor.
1.561 +
1.562 + @return KErrNone if successful.
1.563 + */
1.564 + inline TInt SetConfigurationDescriptor(const TDesC8& aConfigurationDescriptor);
1.565 +
1.566 + /** Gets the size of the current configuration descriptor.
1.567 +
1.568 + @param aSize Receives the size of the current configuration descriptor.
1.569 +
1.570 + @return KErrNone if successful.
1.571 + */
1.572 + inline TInt GetConfigurationDescriptorSize(TInt& aSize);
1.573 +
1.574 + /** Copies the interface descriptor into aInterfaceDescriptor for the interface with alternate
1.575 + setting aSettingNumber, 0 for the main interface.
1.576 +
1.577 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.578 + @param aInterfaceDescriptor Receives the interface descriptor.
1.579 +
1.580 + @return KErrNone if successful.
1.581 + */
1.582 + inline TInt GetInterfaceDescriptor(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
1.583 +
1.584 + /** Sets the interface descriptor contained in aInterfaceDescriptor for the interface with
1.585 + alternate setting aSettingNumber, 0 for the main interface, for transmission to the host
1.586 + during enumeration.
1.587 +
1.588 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.589 + @param aInterfaceDescriptor Contains the interface descriptor to be set.
1.590 +
1.591 + @return KErrNone if successful.
1.592 + */
1.593 + inline TInt SetInterfaceDescriptor(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
1.594 +
1.595 + /** Copies the size of the interface descriptor for the interface with alternate
1.596 + setting aSettingNumber, 0 for the main interface, into aSize.
1.597 +
1.598 + @param aSettingNumber The alternate setting.
1.599 + @param aSize receives the size of the interface descriptor.
1.600 +
1.601 + @return KErrNone if successful.
1.602 + */
1.603 + inline TInt GetInterfaceDescriptorSize(TInt aSettingNumber, TInt& aSize);
1.604 +
1.605 + /** Copies the endpoint descriptor for logical endpoint number aEndpointNumber into aEndpointDescriptor
1.606 + for the interface with alternate setting aSettingNumber, 0 for the main interface.
1.607 +
1.608 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.609 + @param aEndpointNumber The endpoint number of the endpoint.
1.610 + @param aEndpointDescriptor Receives the endpoint descriptor.
1.611 +
1.612 + @return KErrNone if successful.
1.613 + */
1.614 + inline TInt GetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber, TDes8& aEndpointDescriptor);
1.615 +
1.616 + /** Sets the endpoint descriptor for logical endpoint number aEndpointNumber contained in
1.617 + aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
1.618 + for transmission to the host during enumeration.
1.619 +
1.620 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.621 + @param aEndpointNumber Valid endpoint number on this interface.
1.622 + @param aEndpointDescriptor Contains the endpoint descriptor to be set.
1.623 +
1.624 + @return KErrNone if successful.
1.625 + */
1.626 + inline TInt SetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber,
1.627 + const TDesC8& aEndpointDescriptor);
1.628 +
1.629 + /** Copies the size of the endpoint descriptor for logical endpoint number aEndpointNumber for the
1.630 + interface with alternate setting aSettingNumber, 0 for the main interface, into aSize.
1.631 +
1.632 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.633 + @param aEndpointNumber Valid endpoint number on this interface.
1.634 + @param aSize Receives the size of the endpoint descriptor.
1.635 +
1.636 + @return KErrNone if successful.
1.637 + */
1.638 + inline TInt GetEndpointDescriptorSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
1.639 +
1.640 + /** Get OTG descriptor size
1.641 +
1.642 + @param aSize TInt Reference which contains OTG descriptor size on return.
1.643 + */
1.644 + inline void GetOtgDescriptorSize(TInt& aSize);
1.645 +
1.646 + /** Get OTG descriptor of USB on-the-go feature.
1.647 +
1.648 + @param aOtgDesc User-side buffer to store copy of descriptor.
1.649 +
1.650 + @return KErrNone if successful.
1.651 + */
1.652 + inline TInt GetOtgDescriptor(TDes8& aOtgDesc);
1.653 +
1.654 + /** Set OTG descriptor by user to enable/disable USB on-the-go feature.
1.655 +
1.656 + @param aOtgDesc Descriptor buffer containing OTG features.
1.657 +
1.658 + @return KErrNone if successful.
1.659 + */
1.660 + inline TInt SetOtgDescriptor(const TDesC8& aOtgDesc);
1.661 +
1.662 + /** Copies the current device_qualifier descriptor into aDescriptor.
1.663 +
1.664 + @param aDescriptor Receives the current device_qualifier descriptor.
1.665 +
1.666 + @return KErrNone if successful.
1.667 + */
1.668 + inline TInt GetDeviceQualifierDescriptor(TDes8& aDescriptor);
1.669 +
1.670 + /** Sets the device_qualifier descriptor to the contents of aDescriptor.
1.671 +
1.672 + @param aDescriptor Contains the new device_qualifier descriptor.
1.673 +
1.674 + @return KErrNone if successful.
1.675 + */
1.676 + inline TInt SetDeviceQualifierDescriptor(const TDesC8& aDescriptor);
1.677 +
1.678 + /** Copies the current other_speed_configuration descriptor into aDescriptor.
1.679 +
1.680 + @param aDescriptor Receives the current other_speed_configuration descriptor.
1.681 +
1.682 + @return KErrNone if successful.
1.683 + */
1.684 + inline TInt GetOtherSpeedConfigurationDescriptor(TDes8& aDescriptor);
1.685 +
1.686 + /** Sets the other_speed_configuration descriptor to the contents of aDescriptor.
1.687 +
1.688 + @param aDescriptor Contains the new other_speed_configuration descriptor.
1.689 +
1.690 + @return KErrNone if successful.
1.691 + */
1.692 + inline TInt SetOtherSpeedConfigurationDescriptor(const TDesC8& aDescriptor);
1.693 +
1.694 + /** Copies the class specific interface descriptor block into aInterfaceDescriptor for the interface
1.695 + with alternate setting aSettingNumber, 0 for the main interface.
1.696 +
1.697 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.698 + @param aInterfaceDescriptor Contains the interface descriptor to be set.
1.699 +
1.700 + @return KErrNone if successful.
1.701 + */
1.702 + inline TInt GetCSInterfaceDescriptorBlock(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
1.703 +
1.704 + /** aSettingNumber is the alternate interface setting, 0 for the main interface, that the descriptor block
1.705 + aDes should be attached to. aDes is a block of data containing at least one class specific descriptor
1.706 + for transmission during enumeration after the class interface descriptor (or alternate interface
1.707 + descriptor) has been sent, but before the endpoint descriptors belonging to this interface are sent.
1.708 + aDes may contain as many descriptors as are necessary or only one. SetCSInterfaceDescriptorBlock()
1.709 + should be called at any time after SetInterface() has been called to establish a main interface or an
1.710 + alternate interface. More than one call may be made - the data blocks will be concatenated prior to
1.711 + sending. No checking or validation of the contents of aDes will be made and it is the caller's
1.712 + responsibility to ensure that the data supplied is correct and appropriate to the interface identified
1.713 + by aSettingNumber.
1.714 +
1.715 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.716 + @param aInterfaceDescriptor Contains the interface descriptor to be set.
1.717 +
1.718 + @return KErrNone if successful.
1.719 + */
1.720 + inline TInt SetCSInterfaceDescriptorBlock(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
1.721 +
1.722 + /** Copies the size of the class specific interface descriptor block for the interface with alternate
1.723 + setting aSettingNumber, 0 for the main interface, into aSize.
1.724 +
1.725 + @param aSettingNumber The alternate setting number.
1.726 + @param aSize receives the size of the interface descriptor.
1.727 +
1.728 + @return KErrNone if successful.
1.729 + */
1.730 + inline TInt GetCSInterfaceDescriptorBlockSize(TInt aSettingNumber, TInt& aSize);
1.731 +
1.732 + /** Copies the class specific endpoint descriptor for logical endpoint number aEndpointNumber
1.733 + into aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main
1.734 + interface.
1.735 +
1.736 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.737 + @param aEndpointNumber Valid endpoint number on this interface.
1.738 + @param aEndpointDescriptor Receives the endpoint descriptor.
1.739 +
1.740 + @return KErrNone if successful.
1.741 + */
1.742 + inline TInt GetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
1.743 + TDes8& aEndpointDescriptor);
1.744 +
1.745 + /** Sets the class specific endpoint descriptor for logical endpoint number aEndpointNumber contained in
1.746 + aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
1.747 + for transmission to the host during enumeration.
1.748 +
1.749 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.750 + @param aEndpointNumber Valid endpoint number on this interface.
1.751 + @param aEndpointDescriptor Contains the endpoint descriptor to be set.
1.752 +
1.753 + @return KErrNone if successful.
1.754 + */
1.755 + inline TInt SetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
1.756 + const TDesC8& aEndpointDescriptor);
1.757 +
1.758 + /** Copies the size of the class specific endpoint descriptor block for logical endpoint number
1.759 + aEndpointNumber for the interface with alternate setting aSettingNumber, 0 for the main interface,
1.760 + into aSize.
1.761 +
1.762 + @param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
1.763 + @param aEndpointNumber Valid endpoint number on this interface.
1.764 + @param aSize On return, contains the size of the class specific endpoint descriptor block.
1.765 +
1.766 + @return KErrNone if successful.
1.767 + */
1.768 + inline TInt GetCSEndpointDescriptorBlockSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
1.769 +
1.770 + /** Generates a Remote Wakeup bus condition.
1.771 + The capability of the device to generate Remote Wakeup signalling is enquired in
1.772 + RDevUsbcClient::DeviceCaps.
1.773 +
1.774 + @return KErrNone if this signalling is possible and the signal has been generated.
1.775 + */
1.776 + inline TInt SignalRemoteWakeup();
1.777 +
1.778 + /** Simulates a physical removal of the USB cable by disabling the D+/- pull-ups.The iConnect member of
1.779 + TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(), indicates whether this functionality is
1.780 + supported.
1.781 +
1.782 + @return KErrNone if successful.
1.783 + */
1.784 + inline TInt DeviceDisconnectFromHost();
1.785 +
1.786 + /** Simulates a physical insertion of the USB cable by enabling the D+/- pull-ups.The iConnect member
1.787 + of TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(), indicates whether this functionality
1.788 + is supported.
1.789 +
1.790 + @return KErrNone if successful.
1.791 + */
1.792 + inline TInt DeviceConnectToHost();
1.793 +
1.794 + /** Powers up the UDC and connects it to the bus if one or more interfaces exist.
1.795 +
1.796 + @return KErrNone if UDC successfully powered up, KErrNotReady if no
1.797 + interfaces have been registered yet, KErrHardwareNotAvailable if UDC
1.798 + couldn't be activated.
1.799 + */
1.800 + inline TInt PowerUpUdc();
1.801 +
1.802 + /** Enquires about the current operating speed of the UDC.
1.803 +
1.804 + @return ETrue if the UDC is currently operating at High speed, EFalse otherwise.
1.805 + */
1.806 + inline TBool CurrentlyUsingHighSpeed();
1.807 +
1.808 + /** Allocates the use of aResource to aEndpoint. It will be used from when the current bus transfer has been
1.809 + completed.
1.810 +
1.811 + @param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
1.812 + behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
1.813 + @param aEndpoint The endpoint number to which the resource is to be allocated.
1.814 +
1.815 + @return KErrNone if successful, KErrInUse if the resource is already consumed and cannot be allocated,
1.816 + KErrNotSupported if the endpoint does not support the resource requested.
1.817 +
1.818 + @publishedPartner @deprecated
1.819 + */
1.820 + inline TInt AllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
1.821 +
1.822 + /** Deallocates the use of aResource aEndpoint or ends a specified endpoint behaviour.
1.823 +
1.824 + @param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
1.825 + behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
1.826 + @param aEndpoint The endpoint number from which the resource is to be removed.
1.827 +
1.828 + @return KErrNone if the resource has been successfully deallocated, KErrNotSupported if the endpoint
1.829 + does not support the resource requested.
1.830 +
1.831 + @publishedPartner @deprecated
1.832 + */
1.833 + inline TInt DeAllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
1.834 +
1.835 + /** Queries endpoint resource use.
1.836 +
1.837 + @param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
1.838 + behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
1.839 + @param aEndpoint The endpoint number at which the resource is to be queried.
1.840 +
1.841 + @return ETrue is the specified resource is in use at the endpoint and EFalse if not.
1.842 + */
1.843 + inline TBool QueryEndpointResourceUse(TInt aEndpoint, TUsbcEndpointResource aResource);
1.844 +
1.845 + /** Request (i.e. claim for this channel) up to five endpoints and set the class type for this USB
1.846 + interface. 'aInterfaceData' is a package buffer which describes the interface and all the endpoints
1.847 + being requested by the driver for this interface.
1.848 +
1.849 + @param aInterfaceNumber Distinguishes between alternate interfaces. If these are not be used then this
1.850 + should always be zero. If this parameter is used, then its value must be one more than that of the
1.851 + proceeding alternate interface.
1.852 + @param aInterfaceData A package buffer which describes the interface and all the endpoints being
1.853 + requested by the driver for this interface.
1.854 +
1.855 +
1.856 + @return KErrInUse if any of the endpoints being requested have already been claimed by another channel.
1.857 + KErrNotSupported if an endpoint with all of the specified properties is not supported on this
1.858 + platform. KErrNoMemory if insufficient memory is available to complete the operation.
1.859 + */
1.860 + inline TInt SetInterface(TInt aInterfaceNumber, TUsbcScInterfaceInfoBuf& aInterfaceData);
1.861 +
1.862 +
1.863 + /**
1.864 + This method should be called after SetInterface has been called for all possible alternative settings.
1.865 + Calling this invalidates further calls to SetInterface. On success, a chunk handle is created and
1.866 + passed back though aChunk. This is needed for the user side to access the shared chunk where the
1.867 + data is stored. Note that if you are using the BIL (described later), then FinalizeInterface (...)
1.868 + should be used instead, which will call this method.
1.869 +
1.870 + @return KErrNone on successful completion, or one of the system wide error codes.
1.871 + */
1.872 + inline TInt RealizeInterface(RChunk& aChunk);
1.873 +
1.874 +
1.875 + /** Release an interface previously claimed by this channel. Alternate interfaces need to be released
1.876 + in strict descending order, starting with the last (i.e. highest numbered) one.
1.877 + It is not necessary to release an interface that wasn't successfully requested.
1.878 +
1.879 + @param aInterfaceNumber Specifies the alternate setting number 'aInterfaceNum' of the interface to be
1.880 + released.
1.881 +
1.882 + @return KErrNone if successful. KErrArgument if the alternate setting doesn't exist or is released out
1.883 + of order.
1.884 + */
1.885 + inline TInt ReleaseInterface(TInt aInterfaceNumber);
1.886 +
1.887 + /** Copies the current string descriptor language ID (LANGID) code into the aLangId argument. Even though
1.888 + the USB spec allows for the existence of a whole array of LANGID codes, we only support one.
1.889 +
1.890 + @param aLangId Receives the LANGID code.
1.891 +
1.892 + @return KErrNone if successful, KErrArgument if problem with argument (memory cannot be written to, etc.).
1.893 + */
1.894 + inline TInt GetStringDescriptorLangId(TUint16& aLangId);
1.895 +
1.896 + /** Sets the string descriptor language ID (LANGID). Even though the USB spec allows for the existence of
1.897 + a whole array of LANGID codes, we only support one.
1.898 +
1.899 + @param aLangId The LANGID code to be set.
1.900 +
1.901 + @return KErrNone if successful.
1.902 + */
1.903 + inline TInt SetStringDescriptorLangId(TUint16 aLangId);
1.904 +
1.905 + /** Copies the string descriptor identified by the iManufacturer index field of the Standard Device
1.906 + Descriptor into the aString argument.
1.907 +
1.908 + @param aString Receives manufacturer string.
1.909 +
1.910 + @return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
1.911 + descriptor, KErrNotFound if the string descriptor couldn't be found.
1.912 + */
1.913 + inline TInt GetManufacturerStringDescriptor(TDes16& aString);
1.914 +
1.915 + /** Sets the string descriptor identified by the iManufacturer index field of the Standard Device
1.916 + Descriptor to the aString argument.
1.917 +
1.918 + @param aString Contains the new manufacturer string descriptor.
1.919 +
1.920 + @return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
1.921 + aString (in which case the old string descriptor will be preserved).
1.922 + */
1.923 + inline TInt SetManufacturerStringDescriptor(const TDesC16& aString);
1.924 +
1.925 + /** Removes (deletes) the string descriptor identified by the iManufacturer index field of the Standard
1.926 + Device Descriptor and sets that field to zero.
1.927 +
1.928 + @return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
1.929 + */
1.930 + inline TInt RemoveManufacturerStringDescriptor();
1.931 +
1.932 + /** Retrieves the string descriptor identified by the iProduct index field of the Standard Device
1.933 + Descriptor into the aString argument.
1.934 +
1.935 + @param aString Receives product string.
1.936 +
1.937 + @return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
1.938 + descriptor, KErrNotFound if the string descriptor couldn't be found.
1.939 + */
1.940 + inline TInt GetProductStringDescriptor(TDes16& aString);
1.941 +
1.942 + /** Sets the string descriptor identified by the iProduct index field of the Standard Device Descriptor to
1.943 + the aString argument.
1.944 +
1.945 + @param aString Contains the new product string descriptor.
1.946 +
1.947 + @return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
1.948 + aString (in which case the old string descriptor will be preserved).
1.949 + */
1.950 + inline TInt SetProductStringDescriptor(const TDesC16& aString);
1.951 +
1.952 + /** Removes (deletes) the string descriptor identified by the iProduct index field of the Standard Device
1.953 + Descriptor and sets that field to zero.
1.954 +
1.955 + @return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
1.956 + */
1.957 + inline TInt RemoveProductStringDescriptor();
1.958 +
1.959 + /** Retrieves the string descriptor identified by the iSerialNumber index field of the Standard Device
1.960 + Descriptor into the aString argument.
1.961 +
1.962 + @param aString Receives product string.
1.963 +
1.964 + @return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
1.965 + descriptor, KErrNotFound if the string descriptor couldn't be found.
1.966 + */
1.967 + inline TInt GetSerialNumberStringDescriptor(TDes16& aString);
1.968 +
1.969 + /** Sets the string descriptor identified by the iSerialNumber index field of the Standard Device
1.970 + Descriptor to the aString argument.
1.971 +
1.972 + @param aString Contains the new serial number string descriptor.
1.973 +
1.974 + @return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
1.975 + aString (in which case the old string descriptor will be preserved).
1.976 + */
1.977 + inline TInt SetSerialNumberStringDescriptor(const TDesC16& aString);
1.978 +
1.979 + /** Removes (deletes) the string descriptor identified by the iSerialNumber index field of the Standard
1.980 + Device Descriptor and sets that field to zero.
1.981 +
1.982 + @return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
1.983 + */
1.984 + inline TInt RemoveSerialNumberStringDescriptor();
1.985 +
1.986 + /** Retrieves the string descriptor identified by the iConfiguration index field of the (first) Standard
1.987 + Configuration Descriptor into the aString argument.
1.988 +
1.989 + @param aString Receives configuration string.
1.990 +
1.991 + @return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
1.992 + descriptor, KErrNotFound if the string descriptor couldn't be found.
1.993 + */
1.994 + inline TInt GetConfigurationStringDescriptor(TDes16& aString);
1.995 +
1.996 + /** Sets the string descriptor identified by the iConfiguration index field of the Standard Configuration
1.997 + Descriptor to the aString argument.
1.998 +
1.999 + @param aString Contains the new serial number string descriptor.
1.1000 +
1.1001 + @return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
1.1002 + aString (in which case the old string descriptor will be preserved).
1.1003 + */
1.1004 + inline TInt SetConfigurationStringDescriptor(const TDesC16& aString);
1.1005 +
1.1006 + /** Removes (deletes) the string descriptor identified by the iConfiguration index field of the Standard
1.1007 + Configuration Descriptor and sets that field to zero.
1.1008 +
1.1009 + @return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
1.1010 + */
1.1011 + inline TInt RemoveConfigurationStringDescriptor();
1.1012 +
1.1013 + /** Copies the string of the USB string descriptor at the specified index in the string descriptor array
1.1014 + into the aString argument.
1.1015 +
1.1016 + Although this function can also be used for it, for querying most standard string descriptors
1.1017 + there exists a set of dedicated access functions.
1.1018 +
1.1019 + @see RDevUsbcClient::GetStringDescriptorLangId
1.1020 + @see RDevUsbcClient::GetManufacturerStringDescriptor
1.1021 + @see RDevUsbcClient::GetProductStringDescriptor
1.1022 + @see RDevUsbcClient::GetSerialNumberStringDescriptor
1.1023 + @see RDevUsbcClient::GetConfigurationStringDescriptor
1.1024 +
1.1025 + @param aIndex The position of the string descriptor in the string descriptor array.
1.1026 + @param aString The target location for the string descriptor copy.
1.1027 +
1.1028 + @return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index,
1.1029 + KErrArgument if MaxLength() of aString is too small to hold the entire descriptor.
1.1030 + */
1.1031 + inline TInt GetStringDescriptor(TUint8 aIndex, TDes16& aString);
1.1032 +
1.1033 + /** Sets the aString argument to be the string of a USB string descriptor at the specified index in the
1.1034 + string descriptor array. If a string descriptor already exists at that position then its string will
1.1035 + be replaced.
1.1036 +
1.1037 + Care should be taken, when choosing aIndex, not to inadvertently overwrite one of the standard
1.1038 + string descriptors. For their manipulation there exists a set of dedicated access functions.
1.1039 +
1.1040 + @see RDevUsbcClient::SetStringDescriptorLangId
1.1041 + @see RDevUsbcClient::SetManufacturerStringDescriptor
1.1042 + @see RDevUsbcClient::SetProductStringDescriptor
1.1043 + @see RDevUsbcClient::SetSerialNumberStringDescriptor
1.1044 + @see RDevUsbcClient::SetConfigurationStringDescriptor
1.1045 +
1.1046 + @param aIndex The position of the string descriptor in the string descriptor array.
1.1047 + @param aString Contains the string descriptor to be set.
1.1048 +
1.1049 + @return KErrNone if successful, KErrArgument if aIndex is invalid, KErrNoMemory if no memory
1.1050 + is available to store the new string (an existing descriptor at that index will be preserved).
1.1051 + */
1.1052 + inline TInt SetStringDescriptor(TUint8 aIndex, const TDesC16& aString);
1.1053 +
1.1054 + /** Removes (deletes) the USB string descriptor at the specified index in the string descriptor array.
1.1055 + The position in the array of other string descriptors is not affected.
1.1056 +
1.1057 + Care should be taken, when choosing aIndex, not to inadvertently delete a standard string descriptor
1.1058 + (also because index references from non-string descriptors would be invalidated). For the deletion
1.1059 + of most standard string descriptors there exists a set of dedicated functions.
1.1060 +
1.1061 + @see RDevUsbcClient::RemoveManufacturerStringDescriptor
1.1062 + @see RDevUsbcClient::RemoveProductStringDescriptor
1.1063 + @see RDevUsbcClient::RemoveSerialNumberStringDescriptor
1.1064 + @see RDevUsbcClient::RemoveConfigurationStringDescriptor
1.1065 +
1.1066 + @param aIndex The position of the string descriptor in the string descriptor array.
1.1067 +
1.1068 + @return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index.
1.1069 + */
1.1070 + inline TInt RemoveStringDescriptor(TUint8 aIndex);
1.1071 +
1.1072 +
1.1073 +
1.1074 + /** Requests notification for when there is data available on the buffer indicated. If the buffer
1.1075 + already has data in it, it will return immediately, otherwise it will block until there is.
1.1076 +
1.1077 + If the BIL methods are being used (recommended), then this method should not be called directly,
1.1078 + using TEndpointBuffer::GetBuffer instead.
1.1079 +
1.1080 + @param aBufferNumber Indicates the buffer for which the caller wishes to know about data
1.1081 + additions. The buffer needed of any given endpoint can be found by inspecting the alternative
1.1082 + setting table, in the chunk header. The location of the buffer can be found by looking at the
1.1083 + buffer offset table, also in the chunk header.
1.1084 +
1.1085 + @param aStatus The request status where notification of completion is directed. KErrCancel is
1.1086 + returned if the asynchronous operation was cancelled.
1.1087 +
1.1088 + @param aLength A preference for the quantity of data to be read. This value is only a
1.1089 + suggestion and my be ignored. The default value of 0 indicates no preference.
1.1090 +
1.1091 + @return KErrNone on success, or KErrArgument if the buffer number is invalid.
1.1092 + */
1.1093 + inline TInt ReadDataNotify(TInt aBufferNumber, TRequestStatus& aStatus, TInt aLength=0);
1.1094 +
1.1095 +
1.1096 + /** Requests the LDD to write the contents of the given buffer to the USB hardware. Notification is
1.1097 + given when this is complete. More then one write request can be queued on any one endpoint, to allow
1.1098 + for less Hardware idling between buffers.
1.1099 +
1.1100 + If the BIL methods are being used (recommended), then this method should not be called directly,
1.1101 + using TEndpointBuffer::WriteBuffer instead.
1.1102 +
1.1103 + @param aBufferNumber represents the buffer number of the buffer of which the caller has placed the
1.1104 + data. As described with ReadDataNotify(...), details of the buffers can be found in the chunk header.
1.1105 +
1.1106 + @param aStart Represents the start offset of the data within the chunk. This start location must be
1.1107 + aligned to a multiple of the maximum packet size for the endpoint, so that the data can be DMAed
1.1108 + straight out of the buffer.
1.1109 +
1.1110 + @param aLength Represents the amount of data to be sent to the host in bytes.
1.1111 +
1.1112 + @param aFlags Is a bitfield, where bit 0 should be set if a ZLP is to be sent to the host after the
1.1113 + current transaction. All other bits are reserved for future use.
1.1114 +*/
1.1115 + inline void WriteData(TInt aBufferNumber, TUint aStart, TUint aLength, TUint aFlags, TRequestStatus& aStatus);
1.1116 +
1.1117 +
1.1118 +
1.1119 + /** Cancels an outstanding read request on endpoint buffer aBufferNumber.
1.1120 +
1.1121 + @param aBufferNumber The endpoint buffer number whose read is to be cancelled.
1.1122 + */
1.1123 + inline void ReadCancel(TInt aBufferNumber);
1.1124 +
1.1125 +
1.1126 + /** Cancels an outstanding write request on endpoint buffer aBufferNumber.
1.1127 +
1.1128 + @param aBufferNumber The endpoint buffer number whose write is to be cancelled.
1.1129 + */
1.1130 + inline void WriteCancel(TInt aBufferNumber);
1.1131 +
1.1132 + /** Cancels any transfer on any endpoint buffer specified in aBufferMask.
1.1133 +
1.1134 + @code
1.1135 + // Cancel transfer requests on buffers 1, 2, 3 & 4
1.1136 + usbPort.EndpointTransferCancel(1 | 2 | 4 | 8);
1.1137 + @endcode
1.1138 +
1.1139 + @param aBufferMask bitmap of the endpoint buffer numbers.
1.1140 + */
1.1141 + inline void EndpointTransferCancel(TUint aBufferMask);
1.1142 +
1.1143 + /** Register for notification when a change of the Interface alternate setting or the USB Controller's
1.1144 + current state occurs. When the alternate setting or the Controller state changes, then the
1.1145 + asynchronous function completes and the current alternate setting number or Controller state is
1.1146 + written back to aValue. If the KUsbAlternateSetting bit is set then the remaining bits are the
1.1147 + alternate setting number. Otherwise aValue is interpreted as a TUsbcDeviceState.
1.1148 +
1.1149 + @see TUsbcDeviceState
1.1150 +
1.1151 + @param aStatus The request status.
1.1152 + @param aValue Receives the alternate setting number or Controller state.
1.1153 + */
1.1154 + inline void AlternateDeviceStatusNotify(TRequestStatus& aStatus, TUint& aValue);
1.1155 +
1.1156 + /** Completes an AlternateDeviceStatusNotify request. If a request has previously been made then the
1.1157 + status variable is updated with the current device state.
1.1158 + */
1.1159 + inline void AlternateDeviceStatusNotifyCancel();
1.1160 +
1.1161 + /** If the channel has changed the grouping of endpoints between interfaces or changed the interface class
1.1162 + type from the defaults then it is necessary to force a re-enumeration. This will typically involve the
1.1163 + Symbian OS device initiating a disconnection and re-connection. This is an asynchronous operation
1.1164 + which will complete when the Controller is successfully configured by the host, i.e. has achieved
1.1165 + EUsbcDeviceStateConfigured. Since it is not known if the operation has failed, at the same time that
1.1166 + a ReEnumerate request is made, a timer should be set up to complete after approximately 5 seconds. It
1.1167 + can be assumed that if the operation has not completed after this time interval then it will not
1.1168 + complete.
1.1169 +
1.1170 + @param aStatus The request status.
1.1171 + */
1.1172 + inline void ReEnumerate(TRequestStatus& aStatus);
1.1173 +
1.1174 + /** Cancels an outstanding ReEnumerate() request.
1.1175 + */
1.1176 + inline void ReEnumerateCancel();
1.1177 +
1.1178 + /** Register for notification when a change in stall status of any of the interface's endpoints occurs,
1.1179 + but not ep0. When a change in stall status occurs, then the asynchronous function completes and the
1.1180 + current stall state is written back to 'aEndpointStatus' as a bit map: Only stall state changes caused
1.1181 + by SET_FEATURE and CLEAR_FEATURE standard commands on ep0 will be notified when this function
1.1182 + completes. After this request completes the request should be re-issued to obtain future
1.1183 + notifications.
1.1184 +
1.1185 + @param aStatus The request status.
1.1186 + @param aEndpointMask A bitmap of the endpoints' stall status. This is filled in when the call completes.
1.1187 + bit 1 represents the interface's virtual endpoint 1, (KUsbcEndpoint1Bit)
1.1188 + bit 2 represents the interface's virtual endpoint 2, (KUsbcEndpoint2Bit) etc.
1.1189 + bit value 0 - not stalled,
1.1190 + bit value 1 - stalled.
1.1191 + */
1.1192 + inline void EndpointStatusNotify(TRequestStatus& aStatus, TUint& aEndpointMask);
1.1193 +
1.1194 + /** Completes an endpoint status notify request.
1.1195 + */
1.1196 + inline void EndpointStatusNotifyCancel();
1.1197 +
1.1198 + /** Get current on-the-go features relating to the ability of device/host pair to
1.1199 + perform OTG role swap.
1.1200 +
1.1201 + @param aFeatures On return it contains features the device currently has.
1.1202 + bit 2 represents b_hnp_enable, (KUsbOtgAttr_B_HnpEnable)
1.1203 + bit 3 represents a_hnp_support, (KUsbOtgAttr_A_HnpSupport)
1.1204 + bit 4 represents a_alt_hnp_support, (KUsbOtgAttr_A_AltHnpSupport)
1.1205 + @return KErrNone if successful, KErrNotSupported if OTG is not supported by
1.1206 + this device, otherwise system-wide error returns.
1.1207 + */
1.1208 + inline TInt GetOtgFeatures(TUint8& aFeatures);
1.1209 +
1.1210 + /** Register for notification on USB on-the-go features' change. If any OTG feature
1.1211 + is changed, request completes and current feature value is filled in aValue.
1.1212 +
1.1213 + @param aStatus Request status object.
1.1214 + @param aValue On request completion, contains current OTG feature value.
1.1215 + */
1.1216 + inline void OtgFeaturesNotify(TRequestStatus& aStatus, TUint8& aValue);
1.1217 +
1.1218 + /** Cancel pending OTG feature request.
1.1219 + */
1.1220 + inline void OtgFeaturesNotifyCancel();
1.1221 +
1.1222 + /** This function retrieves the alternate setting that the WriteData function can
1.1223 + write to. After a host sets the alternate setting, writes to the IN endpoint
1.1224 + are not permitted by the LDD until this method has been called.
1.1225 + This function is not asynchronous nor blocking, and should not be used to
1.1226 + detect that an alternate setting has happened.
1.1227 +
1.1228 + If the BIL methods are being used (recommended), then this method should not be called directly.
1.1229 +
1.1230 + @return The alternative setting number or KErrInUse if the current alternative
1.1231 + setting is already in use, that is to say that the alternative setting has not changed.
1.1232 + */
1.1233 + inline TInt StartNextInAlternateSetting();
1.1234 +
1.1235 +
1.1236 + /*******************************\
1.1237 + * Buffer Interface Layer (BIL) *
1.1238 + \*******************************/
1.1239 +
1.1240 + // This following functions, as well as the ones in TEndpointBuffer (below),
1.1241 + // can be considered the BIL.
1.1242 +
1.1243 +
1.1244 + /**
1.1245 + Finalize the interface, creating a chunk for use with reading/writing to endpoints.
1.1246 + FinalizeInterface should be called after all alternate interfaces have been set up with SetInteface.
1.1247 + Any attempt to call SetInterface after this stage will fail.
1.1248 +
1.1249 + @return KErrNone if operation is successfull
1.1250 + System wide error codes if chunk creation failed
1.1251 + */
1.1252 + IMPORT_C TInt FinalizeInterface();
1.1253 +
1.1254 + /**
1.1255 + Finalize the interface, creating a chunk for use with reading/writing to endpoints. This
1.1256 + version of the method provides a handle to the chunk, which is needed if the
1.1257 + buffer is to be passed and used by other processes.
1.1258 + FinalizeInterface should be called after all alternate interfaces have been set up with SetInteface.
1.1259 + Any attempt to call SetInterface after this stage will fail.
1.1260 +
1.1261 + @param aChunk On success aChunk points to the created chunk.
1.1262 + @return KErrNone if operation is successfull
1.1263 + System wide error codes if chunk creation failed
1.1264 + */
1.1265 + IMPORT_C TInt FinalizeInterface(RChunk*& aChunk);
1.1266 +
1.1267 + /**
1.1268 + Opens an endpoint, an endpoint should be opened before any operations are attempted on it.
1.1269 +
1.1270 + @param aEpB On success aEpB will be filled with the relevant details for that endpoint
1.1271 + @param aEpI endpoint number to be opened
1.1272 + @return KErrNone if operation is successfull
1.1273 + KErrNotFound if endpoint number is not valid for current alternate setting
1.1274 + KErrInUse if endpoint is already opened
1.1275 + KErrArgument if endpoint buffer argument passed is already in existence and being used
1.1276 + */
1.1277 + IMPORT_C TInt OpenEndpoint(TEndpointBuffer & aEpB, TInt aEpI);
1.1278 +
1.1279 + /**
1.1280 + Switches to processing from one Alternate setting to the next. All open endpoints (except EP0) must
1.1281 + be close before this can be called.
1.1282 +
1.1283 + @param aFlush If ETrue, the method will purge the buffers of any data unread for the old setting.
1.1284 + If each endpoint was not read up until KErrEof was reached, then this should be set.
1.1285 +
1.1286 + @return the alternate Setting if operation is successful
1.1287 + KErrInUse if any endpoints in present alternate setting is still open (except Ep0)
1.1288 + KErrNotReady if there is no change in alternate setting
1.1289 + KErrInUse if StartNextInAlternateSetting detects no change in alternate setting.
1.1290 + KErrCorrupt if the buffer structure becomes corrupt.
1.1291 + */
1.1292 + IMPORT_C TInt StartNextOutAlternateSetting(TBool aFlush);
1.1293 +
1.1294 + /**
1.1295 + Sets aChunk to RChunk currently in use by BIL.
1.1296 +
1.1297 + @param aChunk aChunk will point to RChunk currently in use by BIL
1.1298 + @return KErrNone on success otherwise a system wide error code, if an error has occurred.
1.1299 + */
1.1300 + IMPORT_C TInt GetDataTransferChunk(RChunk*& aChunk);
1.1301 +
1.1302 +private:
1.1303 + /** @internalTechnology */
1.1304 + TInt Drain(TUint aBuffer);
1.1305 + /** @internalTechnology */
1.1306 + TInt Peek(TUint aBuffer);
1.1307 + /** @internalTechnology */
1.1308 + TInt FindNextAlternateSetting();
1.1309 +
1.1310 +private:
1.1311 + TUint8 iEndpointStatus; /** @internalTechnology Each bit corresponds to each endpoint's open/close status. */
1.1312 + RChunk iSharedChunk; /** @internalTechnology The shared chunk in use. */
1.1313 + TInt iAltSettingSeq; /** @internalTechnology Used to track alternate setting changes. */
1.1314 + TInt iAlternateSetting; /** @internalTechnology The alternate setting used by OUT endpoints, which may lag that of IN endpoints. */
1.1315 + TInt iNewAltSetting; /** @internalTechnology Used to track the next alternate setting change on OUT endpoints,
1.1316 + during transition from one to the next. */
1.1317 + TInt iInAltSetting; /** @internalTechnology The alternate setting used by IN endpoints, which may be ahead of OUT endpoints. */
1.1318 +
1.1319 +
1.1320 + friend class TEndpointBuffer;
1.1321 +#endif // #ifndef __KERNEL_MODE__
1.1322 + };
1.1323 +
1.1324 +#ifndef __KERNEL_MODE__
1.1325 +
1.1326 +
1.1327 +/**
1.1328 + This class forms part of the Buffer Interface Layer (BIL), which forms the
1.1329 + user side component of the USB Shared Chunk Client. Objects of this type
1.1330 + represent the shared chunk buffer, for a given endpoint.
1.1331 + The method RDevUsbcScClient::OpenEndpoint() should be used to initialise
1.1332 + objects of this type.
1.1333 +*/
1.1334 +class TEndpointBuffer
1.1335 + {
1.1336 +public:
1.1337 +
1.1338 + /**
1.1339 + This return value used by GetBuffer indicates that the item pointed to by
1.1340 + aBuffer/aOffset represents a state change, instead of endpoint data.
1.1341 + */
1.1342 + const static TInt KStateChange = 0x01;
1.1343 +
1.1344 +public:
1.1345 + IMPORT_C TEndpointBuffer();
1.1346 +
1.1347 + /**
1.1348 + Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process one block of data at a time.
1.1349 + This method also expires the previously read block, meaning that the memory used by the block of data may be re-used by the system, overwriting it
1.1350 + with new data.
1.1351 + @param aBuffer aBuffer will point to data location in shared chunk
1.1352 + @param aSize aSize will hold the number of valid bytes that can be read
1.1353 + @param aZLP aZLP will indicate whether its a short packet or not
1.1354 + @param aStatus In case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for
1.1355 + asynchronous call ReadDataNotify to return
1.1356 + @param aLength Not used at the moment
1.1357 + @return KErrCompletion if operation is successfull and data is available in the buffer
1.1358 + KErrNone if no data is available to be read
1.1359 + KErrEof if alternate setting has changed
1.1360 + KErrAccessDenied if endpoint is not opened
1.1361 + KErrNotSupported if its an IN endpoint
1.1362 + TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
1.1363 + */
1.1364 + IMPORT_C TInt GetBuffer(TAny*& aBuffer,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
1.1365 +
1.1366 + /**
1.1367 + Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process one block of data at a time.
1.1368 + This method also expires the previously read block, meaning that the memory used by the block of data may be re-used by the system, overwriting it
1.1369 + with new data.
1.1370 + @param aOffset aOffset will point to data offset in shared chunk
1.1371 + @param aSize aSize will hold the number of valid bytes that can be read
1.1372 + @param aZLP aZLP will indicate whether its a short packet or not
1.1373 + @param aStatus In case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for
1.1374 + asynchronous call ReadDataNotify to return
1.1375 + @param aLength Not used at the moment
1.1376 + @return KErrCompletion if operation is successfull and data is available in the buffer
1.1377 + KErrNone if no data is available to be read
1.1378 + KErrEof if alternate setting has changed
1.1379 + KErrAccessDenied if endpoint is not opened
1.1380 + KErrNotSupported if its an IN endpoint
1.1381 + TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
1.1382 + */
1.1383 + inline TInt GetBuffer(TUint& aOffset,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
1.1384 +
1.1385 + /**
1.1386 + Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process more than one block of data
1.1387 + simultaneously. The user must call one of the Expire() methods to free the memory used by the block of data, and make it available for new data.
1.1388 + @param aBuffer aBuffer will point to data location in shared chunk
1.1389 + @param aSize aSize will hold the number of valid bytes that can be read
1.1390 + @param aZLP aZLP will indicate whether its a short packet or not
1.1391 + @param aStatus In case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for
1.1392 + asynchronous call ReadDataNotify to return
1.1393 + @param aLength Not used at the moment
1.1394 + @return KErrCompletion if operation is successfull and data is available in the buffer
1.1395 + KErrNone if no data is available to be read
1.1396 + KErrEof if alternate setting has changed
1.1397 + KErrAccessDenied if endpoint is not opened
1.1398 + KErrNotSupported if its an IN endpoint
1.1399 + TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
1.1400 + */
1.1401 + IMPORT_C TInt TakeBuffer(TAny*& aBuffer,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
1.1402 +
1.1403 + /**
1.1404 + Used in conjunction with TakeBuffer method. This will make the 'oldest' block of data previously read out using the TakeBuffer method, but not
1.1405 + already expired, to be released back to the system. This block can then be overwritten with new data, when it becomes available.
1.1406 + @return KErrNotSupported if its an IN endpoint
1.1407 + KErrNone if iTail is successfully bumped to the next transfer to be read
1.1408 + */
1.1409 +
1.1410 + IMPORT_C TInt Expire();
1.1411 +
1.1412 + /**
1.1413 + Used in conjunction with TakeBuffer method. This function allows blocks to be expired in a different order from which the user read the data out
1.1414 + of the buffer. Note that the system will only reuse blocks up to the point of the oldest non-expired block read. This means that the user must
1.1415 + ensure to expire all blocks in a timely manner to prevent the system from running out of usable memory.
1.1416 + @param aAddress aAddress is the start address of the block of data previously read by the user which can be overwritten.
1.1417 + @return KErrNotSupported if its an IN endpoint
1.1418 + KErrNone if iTail is successfully bumped to the next transfer to be read
1.1419 + KErrNotFound if a 'transfer' with start address of the data block is aAddress is not found
1.1420 + */
1.1421 +
1.1422 + IMPORT_C TInt Expire(TAny* aAddress);
1.1423 +
1.1424 + /**
1.1425 + Initiates write operation.
1.1426 + @param aBuffer aBuffer will point to data in shared chunk to be written out. aBuffer should be aligned
1.1427 + @param aSize aSize will hold the number of valid bytes to be written out
1.1428 + @param aZLP aZLP will indicate whether a ZLP should be transmitted after writing the data out
1.1429 + @param aStatus This is an asynchronous function and user side should wait on status to know the end of write operation
1.1430 + @return KErrNone if a write is successfully queued
1.1431 + KErrEof if an alternate setting change has occurred, ending this endpoint.
1.1432 + KErrNotSupported if its an OUT endpoint
1.1433 + KErrAccessDenied if endpoint is not opened, or if buffer is out of range
1.1434 + */
1.1435 + IMPORT_C TInt WriteBuffer(TAny* aBuffer,TUint aSize,TBool aZLP,TRequestStatus& aStatus);
1.1436 +
1.1437 + /**
1.1438 + Initiates write operation.
1.1439 + @param aOffset aOffset will point to offset of data in shared chunk to be written out.
1.1440 + @param aSize aSize will hold the number of valid bytes to be written out
1.1441 + @param aZLP aZLP will indicate whether a ZLP should be transmitted after writing the data out
1.1442 + @param aStatus This is an asynchronous function and user side should wait on status to know the end of write operation
1.1443 + @return KErrNone if a write is successfully queued
1.1444 + KErrEof if an alternate setting change has occurred, ending this endpoint.
1.1445 + KErrNotSupported if its an OUT endpoint
1.1446 + KErrAccessDenied if endpoint is not opened, or if buffer is out of range
1.1447 + */
1.1448 + IMPORT_C TInt WriteBuffer(TUint aOffset,TUint aSize,TBool aZLP,TRequestStatus& aStatus);
1.1449 + /**
1.1450 + For IN endpoints, this method retrieves the geometry for the buffer, for which the
1.1451 + caller should stay within, when using the WriteBuffer method.
1.1452 +
1.1453 + @param aStart A pointer, which is set to point to the start of the buffer.
1.1454 + @param aSize An TUint for which the size (in bytes) of buffer, is written into.
1.1455 +
1.1456 + @returns KErrNotSupported if the object is on an open IN endpoint,
1.1457 + otherwise it KErrNone is returned on success.
1.1458 + */
1.1459 + IMPORT_C TInt GetInBufferRange(TAny*& aStart, TUint& aSize);
1.1460 +
1.1461 + /**
1.1462 + For IN endpoints, this method retrieves the geometry for the buffer, for which the
1.1463 + caller should stay within, when using the WriteBuffer method.
1.1464 +
1.1465 + @param aStart A TUint for which the buffer's start offset from the start of the chunk,
1.1466 + in written into.
1.1467 + @param aSize An TUint for which the size (in bytes) of buffer, is written into.
1.1468 +
1.1469 + @returns KErrNotSupported if the object is on an open IN endpoint,
1.1470 + otherwise it KErrNone is returned on success.
1.1471 + */
1.1472 + IMPORT_C TInt GetInBufferRange(TUint& aStart, TUint& aSize);
1.1473 +
1.1474 + /**
1.1475 + This method closes the endpoint, after it was opened with
1.1476 + RDevUsbcScClient::OpenEndpoint(...).
1.1477 + No method of this object can be used after this call, until
1.1478 + RDevUsbcScClient::OpenEndpoint(...) is called on it again.
1.1479 +
1.1480 + @return KErrNone on success, otherwise KErrNotFound, if the current object is not open.
1.1481 + */
1.1482 + IMPORT_C TInt Close();
1.1483 +
1.1484 + IMPORT_C void Dump();
1.1485 +
1.1486 + /**
1.1487 + Used to retrieve the endpoint number for which this object was open on.
1.1488 +
1.1489 + @returns the endpoint number opened by this object.
1.1490 + */
1.1491 + inline TInt GetEndpointNumber();
1.1492 +
1.1493 +private:
1.1494 + /** @internalTechnology */
1.1495 + void Construct(RDevUsbcScClient* aClient, TUint8* aBaseAddr, const TUsbcScHdrEndpointRecord* aEpType,
1.1496 + TInt aEndpointNumber, SUsbcScBufferHeader* aEndpointHdr=NULL);
1.1497 +
1.1498 +private:
1.1499 + enum TDir {EValid = KErrNone, ENotValid = KErrNotSupported, EEOF = KErrEof};
1.1500 + TDir iInState; /** @internalTechnology describes state of endpoint, KErrNone if IN endpoint and ready to use, KErrNotSupportd if not an IN endpoint, KErrEof on alternate setting change */
1.1501 + TDir iOutState; /** @internalTechnology describes state of endpoint, KErrNone if OUT endpoint and ready to use, KErrNotSupportd if not an OUT endpoint, KErrEoF on alternate setting change */
1.1502 + TInt iEndpointNumber; /** @internalTechnology associated endpoint number */
1.1503 + TInt iBufferNum; /** @internalTechnology buffer number within shared chunk */
1.1504 + RDevUsbcScClient *iClient; /** @internalTechnology Parent RDevUsbcScClient object */
1.1505 + TUint iBaseAddr; /** @internalTechnology The address of the beginning of the Ldd's chunk */
1.1506 +
1.1507 + SUsbcScBufferHeader* iEndpointHdr; /** @internalTechnology Pointer to the buffer Header for OUT/BI endpoints */
1.1508 + TUint8* iBufferStartAddr; /** @internalTechnology IN/BI endpoint buffer start address within shared chunk */
1.1509 + TUint iSize; /** @internalTechnology IN/BI endpoint buffer size within shared chunk */
1.1510 + friend class RDevUsbcScClient;
1.1511 + };
1.1512 +
1.1513 +/**
1.1514 +This class can be used to retrieve the geometry of the structures
1.1515 +within a shared chunk, as used by RDevUsbcScClient.
1.1516 +
1.1517 +@see RDevUsbcScClient
1.1518 +*/
1.1519 +
1.1520 +class TUsbcScChunkHeader
1.1521 + {
1.1522 +public:
1.1523 +/**
1.1524 +The constructor for the TUsbcScChunkHeader class takes a RChunk object,
1.1525 +containing USBcSc data structures, and initialises itself, so that
1.1526 +GetNumberOfEndpoints & GetBuffer can be used to interpret the chunk structures.
1.1527 +
1.1528 +@param An RChunk object, which represents an shared chunk, containing the
1.1529 + USBcSc data structures to be retrieved.
1.1530 +*/
1.1531 + IMPORT_C TUsbcScChunkHeader(RChunk aChunk);
1.1532 +/**
1.1533 +Retrieves the available information in the chunk, about the given endpoint,
1.1534 +on the given alternate setting. The returned TUsbcScBufferRecord,
1.1535 +represents the buffer geometry, used for for the endpoint, while
1.1536 +the filled in TUsbcScHdrEndpointRecord represents additional endpoint
1.1537 +information.
1.1538 +
1.1539 +@param aAltSetting The alternate setting, for which the provided endpoint number, is a member of.
1.1540 +@param aEndpoint The endpoint, who's buffer geometry is required.
1.1541 +@param aEndpointInf The provided record is filled in with details of the endpoint, who's number was given.
1.1542 +*/
1.1543 + IMPORT_C TUsbcScBufferRecord* GetBuffer(TInt aAltSetting, TInt aEndpoint, TUsbcScHdrEndpointRecord*& aEndpointInf);
1.1544 +/**
1.1545 +Retrieves the number of endpoints found in a given alternate setting.
1.1546 +@param aAltSetting The alternate setting number, for which the number of endpoints contained within, is needed.
1.1547 +*/
1.1548 + IMPORT_C TInt GetNumberOfEndpoints(TInt aAltSetting);
1.1549 +
1.1550 +public:
1.1551 + TUsbcScChunkBuffersHeader* iBuffers; /** A pointer to the TUsbcScChunkBuffersHeader object, within the chunk header */
1.1552 + TUsbcScChunkAltSettingHeader* iAltSettings; /** A pointer to the TUsbcScChunkAltSettingHeader object, within the chunk header */
1.1553 +private:
1.1554 + RChunk iChunk;
1.1555 + };
1.1556 +
1.1557 +#endif
1.1558 +
1.1559 +#include <d32usbcsc.inl>
1.1560 +
1.1561 +#endif // __D32USBCSC_H__