189
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\include\d32usbcsc.h
|
|
15 |
// User side class definitions for USB Device support.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file d32usbcsc.h
|
|
21 |
@publishedPartner
|
|
22 |
@released
|
|
23 |
*/
|
|
24 |
|
|
25 |
#ifndef __D32USBCSC_H__
|
|
26 |
#define __D32USBCSC_H__
|
|
27 |
|
|
28 |
#include <e32ver.h>
|
|
29 |
#include <usb.h>
|
|
30 |
#include <d32usbcshared.h>
|
|
31 |
|
|
32 |
|
|
33 |
/** This means that SetInterface was called after RealizeInterface had been called.
|
|
34 |
RealizeInterface is meant to signal that all interfaces have been set.
|
|
35 |
*/
|
|
36 |
const TInt KErrUsbAlreadyRealized = -6813; //Changed from -6713 for future compatibility with the d32usbcshared.h file
|
|
37 |
|
|
38 |
const TInt KErrAlternateSettingChanged = -6814;
|
|
39 |
|
|
40 |
|
|
41 |
const TUint KChunkCellSize = 1; //1 32 bit integer
|
|
42 |
const TInt KEpDescPacketSizeOffset = 4;
|
|
43 |
|
|
44 |
/** The user side enpoint number of Endpoint Zero. */
|
|
45 |
const TInt KEp0Number = 0;
|
|
46 |
|
|
47 |
/* Used in TUsbcScHdrEndpointRecord to describe the endpoint type
|
|
48 |
*/
|
|
49 |
|
|
50 |
const TUint8 KUsbScHdrEpDirectionIn=1;
|
|
51 |
const TUint8 KUsbScHdrEpDirectionOut=2;
|
|
52 |
const TUint8 KUsbScHdrEpDirectionBiDir=3;
|
|
53 |
|
|
54 |
|
|
55 |
const TUint8 KUsbScHdrEpTypeControl = 0;
|
|
56 |
const TUint8 KUsbScHdrEpTypeIsochronous =1;
|
|
57 |
const TUint8 KUsbScHdrEpTypeBulk = 2;
|
|
58 |
const TUint8 KUsbScHdrEpTypeInterrupt = 3;
|
|
59 |
const TUint8 KUsbScHdrEpTypeUnknown = ~0;
|
|
60 |
/** Used in the the Shared Chunk Header, to represent an endpoint.
|
|
61 |
*/
|
|
62 |
class TUsbcScHdrEndpointRecord
|
|
63 |
{
|
|
64 |
public:
|
|
65 |
inline TUsbcScHdrEndpointRecord(TInt aBufferNo, TUint8 aType);
|
|
66 |
inline TUint Direction() const;
|
|
67 |
inline TUint Type() const;
|
|
68 |
public:
|
|
69 |
TUint8 iBufferNo;
|
|
70 |
TUint8 iType;
|
|
71 |
TUint16 iReserved;
|
|
72 |
};
|
|
73 |
|
|
74 |
|
|
75 |
// This is used to hold the geometry of the shared buffers
|
|
76 |
class TUsbcScBufferRecord
|
|
77 |
{
|
|
78 |
friend class DLddUsbcScChannel;
|
|
79 |
|
|
80 |
public:
|
|
81 |
inline TUint Offset() const;
|
|
82 |
inline TUint Size() const;
|
|
83 |
private:
|
|
84 |
inline void Set(TUint aOffset, TUint aEndOffset);
|
|
85 |
TUint iOffset;
|
|
86 |
TUint iSize;
|
|
87 |
};
|
|
88 |
|
|
89 |
struct SUsbcScBufferHeader
|
|
90 |
{
|
|
91 |
TInt iHead; // Where the LDD will next write a transfer
|
|
92 |
TInt iTail; // Indicates the fist packet that user side is processing (anything prior is disposable)
|
|
93 |
TInt iBilTail; // This is not used by LDD at all, but just for the BIL's benifit.
|
|
94 |
};
|
|
95 |
|
|
96 |
|
|
97 |
struct SUsbcScAlternateSetting
|
|
98 |
{
|
|
99 |
TUint16 iSetting;
|
|
100 |
TUint16 iSequence;
|
|
101 |
};
|
|
102 |
|
|
103 |
/** Endpoint pair information. This can be used to control pairing of endpoint
|
|
104 |
for classes that require explicit pairing of endpoint, such as ADC.
|
|
105 |
|
|
106 |
This is currently not used.
|
|
107 |
*/
|
|
108 |
|
|
109 |
class TEndpointPairInfo
|
|
110 |
{
|
|
111 |
public:
|
|
112 |
TEndpointPairInfo(TUint8 aType=0, TUint16 aPair=0, TUint8 aSpare=0);
|
|
113 |
public:
|
|
114 |
TUint8 iType;
|
|
115 |
TUint8 iSpare;
|
|
116 |
TUint16 iPair;
|
|
117 |
};
|
|
118 |
|
|
119 |
/**
|
|
120 |
This is the buffer number reserved for use with endpoint zero with the ReadDataNotify and WriteData methods.
|
|
121 |
*/
|
|
122 |
const TInt KUsbcScEndpointZero = -1;
|
|
123 |
|
|
124 |
/**
|
|
125 |
This flag is reserved in TUsbcscEndpointInfo::iFlags, to indicate that the client driver's client wishes reads to operate in a coupled fashion.
|
|
126 |
This behaviour is not currently supported.
|
|
127 |
*/
|
|
128 |
const TUint KUsbScCoupledRead = 0x1;
|
|
129 |
|
|
130 |
/**
|
|
131 |
This flag, used in parameter aFlag of WriteData, is used to indicate that a ZLP should be sent.
|
|
132 |
*/
|
|
133 |
const TUint KUsbcScWriteFlagsZlp = 0x0001;
|
|
134 |
|
|
135 |
|
|
136 |
// Bit fields used in iFlags of TUsbcScTransferHeader
|
|
137 |
|
|
138 |
const TUint KUsbcScShortPacket = 0x0001;
|
|
139 |
const TUint KUsbcScStateChange = 0x0004;
|
|
140 |
|
|
141 |
class TUsbcScTransferHeader
|
|
142 |
{
|
|
143 |
public:
|
|
144 |
#ifdef _DEBUG
|
|
145 |
TUint iHashId;
|
|
146 |
TUint iSequence;
|
|
147 |
#endif
|
|
148 |
TUint iBytes;
|
|
149 |
TUint iFlags;
|
|
150 |
TUint iNext;
|
|
151 |
TUint16 iAltSettingSeq;
|
|
152 |
TInt16 iAltSetting;
|
|
153 |
union
|
|
154 |
{
|
|
155 |
TUint i[1]; // Extends
|
|
156 |
TUint8 b[4]; // Extends
|
|
157 |
} iData;
|
|
158 |
};
|
|
159 |
|
|
160 |
/** The desired endpoint capabilities used in RDevUsbcScClient::SetInterface().
|
|
161 |
|
|
162 |
This derived class has additional fields used in the shared chunk USB driver.
|
|
163 |
*/
|
|
164 |
class TUsbcScEndpointInfo: public TUsbcEndpointInfo
|
|
165 |
{
|
|
166 |
public:
|
|
167 |
TUsbcScEndpointInfo(TUint aType=KUsbEpTypeBulk, TUint aDir=KUsbEpDirOut, TInt aInterval=0, TInt aExtra=0,
|
|
168 |
TUint aBufferSize=0, TUint aReadSize=0);
|
|
169 |
|
|
170 |
|
|
171 |
public:
|
|
172 |
/** This indicates the requested size of the endpoint buffer and must be at
|
|
173 |
least as large as iReadSize.
|
|
174 |
*/
|
|
175 |
TUint iBufferSize;
|
|
176 |
|
|
177 |
/** This is the amount of data that the LDD reads from the bus before it sets
|
|
178 |
up another read and is normally intended to read many packets.
|
|
179 |
*/
|
|
180 |
TUint iReadSize;
|
|
181 |
|
|
182 |
/** TEndpointPairInfo represents pairing information for isochronous endpoints.
|
|
183 |
Should be zero in other cases. If this specifies paired endpoints then
|
|
184 |
iExtra (in the base class TUsbcEndpointInfo) also needs to be set to the
|
|
185 |
class specific size for this endpoint descriptor (This is here only for future use).
|
|
186 |
*/
|
|
187 |
TEndpointPairInfo iPairing;
|
|
188 |
|
|
189 |
/** The necessary alignment, in bytes, that needs to be applied to the transfer start points
|
|
190 |
of the data. This is only observed on OUT endpoints. Zero can be specified to indicate
|
|
191 |
there are no class side requirements for alignment. The alignment for OUT endpoints is
|
|
192 |
which ever is greater of this field or the USB hardware requirements.
|
|
193 |
*/
|
|
194 |
TUint iAlignment;
|
|
195 |
|
|
196 |
/** Flags to indicate how the endpoint should function. None currently defined,
|
|
197 |
but could be used to allow support for direct read.
|
|
198 |
*/
|
|
199 |
TUint iFlags;
|
|
200 |
|
|
201 |
/** Reserved for future use. */
|
|
202 |
TUint32 iReserved2[2];
|
|
203 |
};
|
|
204 |
|
|
205 |
/** This must be filled in prior to a call to RDevUsbcClient::SetInterface().
|
|
206 |
*/
|
|
207 |
class TUsbcScInterfaceInfo
|
|
208 |
{
|
|
209 |
public:
|
|
210 |
TUsbcScInterfaceInfo(TInt aClass=0, TInt aSubClass=0, TInt aProtocol=0,
|
|
211 |
TDesC16* aString=NULL, TUint aTotalEndpoints=0);
|
|
212 |
public:
|
|
213 |
/** The class, subclass and protocol that this interface supports. */
|
|
214 |
TUsbcClassInfo iClass;
|
|
215 |
/** The description string for the interface. Used to construct the interface string descriptor. */
|
|
216 |
const TDesC16* iString;
|
|
217 |
/** Total number of endpoints being requested (0-5). Endpoint 0 should not be included in this number. */
|
|
218 |
TUint iTotalEndpointsUsed;
|
|
219 |
/** Desired properties of the endpoints requested.
|
|
220 |
Do NOT include endpoint 0.
|
|
221 |
APIs use endpoint numbers that are offsets into this array.
|
|
222 |
*/
|
|
223 |
TUsbcScEndpointInfo iEndpointData[KMaxEndpointsPerClient];
|
|
224 |
/** 32 flag bits used for specifying miscellaneous Interface features.
|
|
225 |
Currently defined are:
|
|
226 |
- KUsbcInterfaceInfo_NoEp0RequestsPlease = 0x00000001
|
|
227 |
*/
|
|
228 |
TUint32 iFeatureWord;
|
|
229 |
};
|
|
230 |
|
|
231 |
/** Package buffer for a TUsbcInterfaceInfo object.
|
|
232 |
|
|
233 |
@see TUsbcInterfaceInfo
|
|
234 |
*/
|
|
235 |
typedef TPckgBuf<TUsbcScInterfaceInfo> TUsbcScInterfaceInfoBuf;
|
|
236 |
|
|
237 |
struct TUsbcScChunkHdrOffs
|
|
238 |
{
|
|
239 |
TUint iBuffers;
|
|
240 |
TUint iAltSettings;
|
|
241 |
};
|
|
242 |
|
|
243 |
|
|
244 |
class TUsbcScChunkBuffersHeader // Not instantiable
|
|
245 |
{
|
|
246 |
friend class DLddUsbcScChannel;
|
|
247 |
friend class TRealizeInfo;
|
|
248 |
|
|
249 |
public:
|
|
250 |
inline TUsbcScBufferRecord* Ep0Out() const;
|
|
251 |
inline TUsbcScBufferRecord* Ep0In() const;
|
|
252 |
inline TUsbcScBufferRecord* Buffers(TInt aBuffer) const;
|
|
253 |
inline TInt NumberOfBuffers() const;
|
|
254 |
|
|
255 |
private:
|
|
256 |
TUsbcScChunkBuffersHeader();
|
|
257 |
private:
|
|
258 |
TInt iRecordSize;
|
|
259 |
TInt iNumOfBufs;
|
|
260 |
TUint8 iBufferOffset[8]; // Extends
|
|
261 |
};
|
|
262 |
|
|
263 |
struct TUsbcScChunkAltSettingHeader // Not instantiable
|
|
264 |
{
|
|
265 |
TInt iEpRecordSize;
|
|
266 |
TInt iNumOfAltSettings;
|
|
267 |
TUint iAltTableOffset[1]; // Extends
|
|
268 |
};
|
|
269 |
|
|
270 |
class TEndpointBuffer;
|
|
271 |
|
|
272 |
|
|
273 |
/** The user side handle to the USB client driver.
|
|
274 |
*/
|
|
275 |
class RDevUsbcScClient : public RBusLogicalChannel
|
|
276 |
{
|
|
277 |
public:
|
|
278 |
/** @internalComponent */
|
|
279 |
enum TVer
|
|
280 |
{
|
|
281 |
EMajorVersionNumber = 0,
|
|
282 |
EMinorVersionNumber = 1,
|
|
283 |
EBuildVersionNumber = KE32BuildVersionNumber
|
|
284 |
};
|
|
285 |
|
|
286 |
// Bit pattern. s = Request/Control. c = Cancel, m = mode bits, B = Buffer number, R = request number.
|
|
287 |
// scmm mmmm | mmmm mmmm | mmBB BBBB |RRRR RRRR
|
|
288 |
|
|
289 |
enum TRequest
|
|
290 |
{
|
|
291 |
ERequestWriteData = 1,
|
|
292 |
ERequestReadDataNotify = 2,
|
|
293 |
ERequestAlternateDeviceStatusNotify = 3,
|
|
294 |
ERequestReEnumerate = 4,
|
|
295 |
ERequestEndpointStatusNotify = 5,
|
|
296 |
ERequestOtgFeaturesNotify = 6,
|
|
297 |
ERequestMaxRequests, // 7
|
|
298 |
|
|
299 |
ERequestCancel = 0x40000000,
|
|
300 |
|
|
301 |
ERequestWriteDataCancel = ERequestWriteData | ERequestCancel,
|
|
302 |
ERequestReadDataNotifyCancel = ERequestReadDataNotify | ERequestCancel,
|
|
303 |
ERequestAlternateDeviceStatusNotifyCancel = ERequestAlternateDeviceStatusNotify | ERequestCancel,
|
|
304 |
ERequestReEnumerateCancel = ERequestReEnumerate | ERequestCancel,
|
|
305 |
ERequestEndpointStatusNotifyCancel = ERequestEndpointStatusNotify | ERequestCancel,
|
|
306 |
ERequestOtgFeaturesNotifyCancel = ERequestOtgFeaturesNotify | ERequestCancel
|
|
307 |
};
|
|
308 |
|
|
309 |
enum TControl
|
|
310 |
{
|
|
311 |
// Changing the order of these enums will break BC.
|
|
312 |
EControlEndpointZeroRequestError, // 00
|
|
313 |
EControlEndpointCaps,
|
|
314 |
EControlDeviceCaps,
|
|
315 |
EControlGetAlternateSetting,
|
|
316 |
EControlDeviceStatus,
|
|
317 |
EControlEndpointStatus,
|
|
318 |
EControlSetInterface,
|
|
319 |
EControlReleaseInterface,
|
|
320 |
EControlSendEp0StatusPacket,
|
|
321 |
EControlHaltEndpoint, // 09
|
|
322 |
//
|
|
323 |
EControlClearHaltEndpoint, // 10
|
|
324 |
EControlSetDeviceControl,
|
|
325 |
EControlReleaseDeviceControl,
|
|
326 |
EControlEndpointZeroMaxPacketSizes,
|
|
327 |
EControlSetEndpointZeroMaxPacketSize,
|
|
328 |
EControlGetDeviceDescriptor,
|
|
329 |
EControlSetDeviceDescriptor,
|
|
330 |
EControlGetDeviceDescriptorSize,
|
|
331 |
EControlGetConfigurationDescriptor,
|
|
332 |
EControlSetConfigurationDescriptor, // 19
|
|
333 |
//
|
|
334 |
EControlGetConfigurationDescriptorSize, // 20
|
|
335 |
EControlGetInterfaceDescriptor,
|
|
336 |
EControlSetInterfaceDescriptor,
|
|
337 |
EControlGetInterfaceDescriptorSize,
|
|
338 |
EControlGetEndpointDescriptor,
|
|
339 |
EControlSetEndpointDescriptor,
|
|
340 |
EControlGetEndpointDescriptorSize,
|
|
341 |
EControlGetCSInterfaceDescriptor,
|
|
342 |
EControlSetCSInterfaceDescriptor,
|
|
343 |
EControlGetCSInterfaceDescriptorSize, // 29
|
|
344 |
//
|
|
345 |
EControlGetCSEndpointDescriptor, // 30
|
|
346 |
EControlSetCSEndpointDescriptor,
|
|
347 |
EControlGetCSEndpointDescriptorSize,
|
|
348 |
EControlSignalRemoteWakeup,
|
|
349 |
EControlGetStringDescriptorLangId,
|
|
350 |
EControlSetStringDescriptorLangId,
|
|
351 |
EControlGetManufacturerStringDescriptor,
|
|
352 |
EControlSetManufacturerStringDescriptor,
|
|
353 |
EControlRemoveManufacturerStringDescriptor,
|
|
354 |
EControlGetProductStringDescriptor, // 39
|
|
355 |
//
|
|
356 |
EControlSetProductStringDescriptor, // 40
|
|
357 |
EControlRemoveProductStringDescriptor,
|
|
358 |
EControlGetSerialNumberStringDescriptor,
|
|
359 |
EControlSetSerialNumberStringDescriptor,
|
|
360 |
EControlRemoveSerialNumberStringDescriptor,
|
|
361 |
EControlGetConfigurationStringDescriptor,
|
|
362 |
EControlSetConfigurationStringDescriptor,
|
|
363 |
EControlRemoveConfigurationStringDescriptor,
|
|
364 |
EControlDeviceDisconnectFromHost,
|
|
365 |
EControlDeviceConnectToHost, // 49
|
|
366 |
//
|
|
367 |
EControlDevicePowerUpUdc, // 50
|
|
368 |
EControlDumpRegisters,
|
|
369 |
EControlAllocateEndpointResource,
|
|
370 |
EControlDeAllocateEndpointResource,
|
|
371 |
EControlQueryEndpointResourceUse,
|
|
372 |
EControlGetEndpointZeroMaxPacketSize,
|
|
373 |
EControlGetDeviceQualifierDescriptor,
|
|
374 |
EControlSetDeviceQualifierDescriptor,
|
|
375 |
EControlGetOtherSpeedConfigurationDescriptor,
|
|
376 |
EControlSetOtherSpeedConfigurationDescriptor, // 59
|
|
377 |
//
|
|
378 |
EControlCurrentlyUsingHighSpeed, // 60
|
|
379 |
EControlSetStringDescriptor,
|
|
380 |
EControlGetStringDescriptor,
|
|
381 |
EControlRemoveStringDescriptor,
|
|
382 |
EControlSetOtgDescriptor,
|
|
383 |
EControlGetOtgDescriptor,
|
|
384 |
EControlGetOtgFeatures,
|
|
385 |
EControlRealizeInterface,
|
189
|
386 |
EControlStartNextInAlternateSetting
|
0
|
387 |
};
|
|
388 |
|
|
389 |
|
|
390 |
// const static TUint KFieldIdPos = 0;
|
|
391 |
const static TUint KFieldIdMask = 0xFF;
|
|
392 |
const static TUint KFieldBuffPos = 8;
|
|
393 |
const static TUint KFieldBuffMask = 0x3F;
|
|
394 |
const static TUint KFieldFlagsPos = 14;
|
|
395 |
const static TUint KFieldFlagsMask = 0xFFFF;
|
|
396 |
|
|
397 |
|
|
398 |
public:
|
|
399 |
|
|
400 |
#ifndef __KERNEL_MODE__
|
|
401 |
|
189
|
402 |
|
0
|
403 |
/** Opens a channel.
|
|
404 |
|
|
405 |
@param aUnit This should be 0 (zero).
|
189
|
406 |
@param aShare if this channel can be used in another process.
|
0
|
407 |
|
|
408 |
@return KErrNone if successful.
|
|
409 |
*/
|
189
|
410 |
inline TInt Open(TInt aUnit, TBool aShare=ETrue);
|
|
411 |
|
|
412 |
/** Opens a channel which has created.
|
|
413 |
|
|
414 |
@param aMsg client-server message contain the handle of this channel.
|
|
415 |
@param aPos index of message slot that contain handle.
|
|
416 |
@param aType ownership type of the handle.
|
|
417 |
|
|
418 |
@return KErrNone if successful.
|
|
419 |
*/
|
|
420 |
|
|
421 |
inline TInt Open(RMessagePtr2 aMsg, TInt aIndex, TOwnerType aType=EOwnerProcess);
|
0
|
422 |
|
|
423 |
inline TVersion VersionRequired() const;
|
|
424 |
|
|
425 |
/** Stalls ep0 to signal command fault to the host.
|
|
426 |
|
|
427 |
@return KErrNone if successful.
|
|
428 |
*/
|
|
429 |
inline TInt EndpointZeroRequestError();
|
|
430 |
|
|
431 |
/** Retrieves the capabilities of all the endpoints on the device.
|
|
432 |
|
|
433 |
Suggested use is as follows:
|
|
434 |
|
|
435 |
@code
|
|
436 |
TUsbcEndpointData data[KUsbcMaxEndpoints];
|
|
437 |
TPtr8 dataPtr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
|
|
438 |
ret = usbPort.EndpointCaps(dataPtr);
|
|
439 |
@endcode
|
|
440 |
|
|
441 |
@param aEpCapsBuf A descriptor encapsulating an array of TUsbcEndpointData.
|
|
442 |
|
|
443 |
@return KErrNone if successful.
|
|
444 |
*/
|
|
445 |
inline TInt EndpointCaps(TDes8& aEpCapsBuf);
|
|
446 |
|
|
447 |
/** Retrieves the capabilities of the USB device.
|
|
448 |
|
|
449 |
@see TUsbDeviceCaps
|
|
450 |
|
|
451 |
@param aDevCapsBuf A TUsbDeviceCaps object.
|
|
452 |
|
|
453 |
@return KErrNone if successful.
|
|
454 |
*/
|
|
455 |
inline TInt DeviceCaps(TUsbDeviceCaps& aDevCapsBuf);
|
|
456 |
|
|
457 |
/** Copies the current alternate setting for this interface into aInterfaceNumber
|
|
458 |
For USB Interfaces whose main interface is active, this will be 0 (zero).
|
|
459 |
|
|
460 |
@param aInterfaceNumber Current alternate setting for this interface is copied into this.
|
|
461 |
|
|
462 |
@return KErrNone if successful.
|
|
463 |
*/
|
|
464 |
inline TInt GetAlternateSetting(TInt& aInterfaceNumber);
|
|
465 |
|
|
466 |
/** Copies the current device status into aDeviceStatus.
|
|
467 |
|
|
468 |
@param aDeviceStatus Current device status is copied into this.
|
|
469 |
|
|
470 |
@return KErrNone if successful
|
|
471 |
*/
|
|
472 |
inline TInt DeviceStatus(TUsbcDeviceState& aDeviceStatus);
|
|
473 |
|
|
474 |
/** Copies the current endpoint status into aEndpointStatus.
|
|
475 |
|
|
476 |
@param aEndpoint Endpoint number valid for the current alternate setting.
|
|
477 |
@param aEndpointStatus The current endpoint status, might be stalled, not stalled or unknown.
|
|
478 |
|
|
479 |
@return KErrNone if successful.
|
|
480 |
*/
|
|
481 |
inline TInt EndpointStatus(TInt aEndpoint, TEndpointState& aEndpointStatus);
|
|
482 |
|
|
483 |
|
|
484 |
/** Requests that a zero length status packet be sent to the host in response
|
|
485 |
to a class or vendor specific ep0 SETUP packet.
|
|
486 |
|
|
487 |
@return KErrNone if successful.
|
|
488 |
*/
|
|
489 |
inline TInt SendEp0StatusPacket();
|
|
490 |
|
|
491 |
/** Stalls endpoint aEndpoint, usually to indicate an error condition with a previous command.
|
|
492 |
The host will normally send a SET_FEATURE command on ep0 to acknowledge and clear the stall.
|
|
493 |
|
|
494 |
@return KErrNone if successful.
|
|
495 |
*/
|
|
496 |
inline TInt HaltEndpoint(TInt aEndpoint);
|
|
497 |
|
|
498 |
/** Clears the stall condition on endpoint aEndpoint. This is inluded for symmetry and test purposes.
|
|
499 |
|
|
500 |
@return KErrNone if successful.
|
|
501 |
*/
|
|
502 |
inline TInt ClearHaltEndpoint(TInt aEndpoint);
|
|
503 |
|
|
504 |
/** Requests that device control be allocated to this channel.
|
|
505 |
|
|
506 |
@return KErrNone if successful.
|
|
507 |
*/
|
|
508 |
inline TInt SetDeviceControl();
|
|
509 |
|
|
510 |
/** Relinquishes device control previously allocated to this channel.
|
|
511 |
|
|
512 |
@return KErrNone if successful.
|
|
513 |
*/
|
|
514 |
inline TInt ReleaseDeviceControl();
|
|
515 |
|
|
516 |
/** Returns a bitmap of available ep0 maximum packet sizes.
|
|
517 |
|
|
518 |
@return bitmap of available ep0 maximum packet sizes.
|
|
519 |
*/
|
|
520 |
inline TUint EndpointZeroMaxPacketSizes();
|
|
521 |
|
|
522 |
/** Requests that a maximum packet size of aMaxPacketSize be set on ep0.
|
|
523 |
|
|
524 |
@param aMaxPacketSize The maximum packet size.
|
|
525 |
|
|
526 |
@return KErrNone if successful.
|
|
527 |
*/
|
|
528 |
inline TInt SetEndpointZeroMaxPacketSize(TInt aMaxPacketSize);
|
|
529 |
|
|
530 |
/** Queries the current maximum packet size on ep0.
|
|
531 |
|
|
532 |
@return The currently set maximum packet size on ep0.
|
|
533 |
*/
|
|
534 |
inline TInt GetEndpointZeroMaxPacketSize();
|
|
535 |
|
|
536 |
/** Copies the current device descriptor into aDeviceDescriptor.
|
|
537 |
|
|
538 |
@param aDeviceDescriptor Receives the current device descriptor.
|
|
539 |
|
|
540 |
@return KErrNone if successful.
|
|
541 |
*/
|
|
542 |
inline TInt GetDeviceDescriptor(TDes8& aDeviceDescriptor);
|
|
543 |
|
|
544 |
/** Sets the contents of aDeviceDescriptor to be the current device descriptor.
|
|
545 |
|
|
546 |
@param aDeviceDescriptor Contains the device descriptor.
|
|
547 |
|
|
548 |
@return KErrNone if successful.
|
|
549 |
*/
|
|
550 |
inline TInt SetDeviceDescriptor(const TDesC8& aDeviceDescriptor);
|
|
551 |
|
|
552 |
/** Gets the size of the current device descriptor. This is unlikely to be anything other than 9.
|
|
553 |
|
|
554 |
@param aSize Receives the size of the current device descriptor.
|
|
555 |
|
|
556 |
@return KErrNone if successful.
|
|
557 |
*/
|
|
558 |
inline TInt GetDeviceDescriptorSize(TInt& aSize);
|
|
559 |
|
|
560 |
/** Copies the current configuration descriptor into aConfigurationDescriptor.
|
|
561 |
|
|
562 |
@param aConfigurationDescriptor Receives the current configuration descriptor.
|
|
563 |
|
|
564 |
@return KErrNone if successful.
|
|
565 |
*/
|
|
566 |
inline TInt GetConfigurationDescriptor(TDes8& aConfigurationDescriptor);
|
|
567 |
|
|
568 |
/** Sets the contents of aConfigurationDescriptor to be the current configuration descriptor.
|
|
569 |
|
|
570 |
@param aConfigurationDescriptor Contains the configuration descriptor.
|
|
571 |
|
|
572 |
@return KErrNone if successful.
|
|
573 |
*/
|
|
574 |
inline TInt SetConfigurationDescriptor(const TDesC8& aConfigurationDescriptor);
|
|
575 |
|
|
576 |
/** Gets the size of the current configuration descriptor.
|
|
577 |
|
|
578 |
@param aSize Receives the size of the current configuration descriptor.
|
|
579 |
|
|
580 |
@return KErrNone if successful.
|
|
581 |
*/
|
|
582 |
inline TInt GetConfigurationDescriptorSize(TInt& aSize);
|
|
583 |
|
|
584 |
/** Copies the interface descriptor into aInterfaceDescriptor for the interface with alternate
|
|
585 |
setting aSettingNumber, 0 for the main interface.
|
|
586 |
|
|
587 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
588 |
@param aInterfaceDescriptor Receives the interface descriptor.
|
|
589 |
|
|
590 |
@return KErrNone if successful.
|
|
591 |
*/
|
|
592 |
inline TInt GetInterfaceDescriptor(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
|
|
593 |
|
|
594 |
/** Sets the interface descriptor contained in aInterfaceDescriptor for the interface with
|
|
595 |
alternate setting aSettingNumber, 0 for the main interface, for transmission to the host
|
|
596 |
during enumeration.
|
|
597 |
|
|
598 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
599 |
@param aInterfaceDescriptor Contains the interface descriptor to be set.
|
|
600 |
|
|
601 |
@return KErrNone if successful.
|
|
602 |
*/
|
|
603 |
inline TInt SetInterfaceDescriptor(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
|
|
604 |
|
|
605 |
/** Copies the size of the interface descriptor for the interface with alternate
|
|
606 |
setting aSettingNumber, 0 for the main interface, into aSize.
|
|
607 |
|
|
608 |
@param aSettingNumber The alternate setting.
|
|
609 |
@param aSize receives the size of the interface descriptor.
|
|
610 |
|
|
611 |
@return KErrNone if successful.
|
|
612 |
*/
|
|
613 |
inline TInt GetInterfaceDescriptorSize(TInt aSettingNumber, TInt& aSize);
|
|
614 |
|
|
615 |
/** Copies the endpoint descriptor for logical endpoint number aEndpointNumber into aEndpointDescriptor
|
|
616 |
for the interface with alternate setting aSettingNumber, 0 for the main interface.
|
|
617 |
|
|
618 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
619 |
@param aEndpointNumber The endpoint number of the endpoint.
|
|
620 |
@param aEndpointDescriptor Receives the endpoint descriptor.
|
|
621 |
|
|
622 |
@return KErrNone if successful.
|
|
623 |
*/
|
|
624 |
inline TInt GetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber, TDes8& aEndpointDescriptor);
|
|
625 |
|
|
626 |
/** Sets the endpoint descriptor for logical endpoint number aEndpointNumber contained in
|
|
627 |
aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
|
|
628 |
for transmission to the host during enumeration.
|
|
629 |
|
|
630 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
631 |
@param aEndpointNumber Valid endpoint number on this interface.
|
|
632 |
@param aEndpointDescriptor Contains the endpoint descriptor to be set.
|
|
633 |
|
|
634 |
@return KErrNone if successful.
|
|
635 |
*/
|
|
636 |
inline TInt SetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber,
|
|
637 |
const TDesC8& aEndpointDescriptor);
|
|
638 |
|
|
639 |
/** Copies the size of the endpoint descriptor for logical endpoint number aEndpointNumber for the
|
|
640 |
interface with alternate setting aSettingNumber, 0 for the main interface, into aSize.
|
|
641 |
|
|
642 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
643 |
@param aEndpointNumber Valid endpoint number on this interface.
|
|
644 |
@param aSize Receives the size of the endpoint descriptor.
|
|
645 |
|
|
646 |
@return KErrNone if successful.
|
|
647 |
*/
|
|
648 |
inline TInt GetEndpointDescriptorSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
|
|
649 |
|
|
650 |
/** Get OTG descriptor size
|
|
651 |
|
|
652 |
@param aSize TInt Reference which contains OTG descriptor size on return.
|
|
653 |
*/
|
|
654 |
inline void GetOtgDescriptorSize(TInt& aSize);
|
|
655 |
|
|
656 |
/** Get OTG descriptor of USB on-the-go feature.
|
|
657 |
|
|
658 |
@param aOtgDesc User-side buffer to store copy of descriptor.
|
|
659 |
|
|
660 |
@return KErrNone if successful.
|
|
661 |
*/
|
|
662 |
inline TInt GetOtgDescriptor(TDes8& aOtgDesc);
|
|
663 |
|
|
664 |
/** Set OTG descriptor by user to enable/disable USB on-the-go feature.
|
|
665 |
|
|
666 |
@param aOtgDesc Descriptor buffer containing OTG features.
|
|
667 |
|
|
668 |
@return KErrNone if successful.
|
|
669 |
*/
|
|
670 |
inline TInt SetOtgDescriptor(const TDesC8& aOtgDesc);
|
|
671 |
|
|
672 |
/** Copies the current device_qualifier descriptor into aDescriptor.
|
|
673 |
|
|
674 |
@param aDescriptor Receives the current device_qualifier descriptor.
|
|
675 |
|
|
676 |
@return KErrNone if successful.
|
|
677 |
*/
|
|
678 |
inline TInt GetDeviceQualifierDescriptor(TDes8& aDescriptor);
|
|
679 |
|
|
680 |
/** Sets the device_qualifier descriptor to the contents of aDescriptor.
|
|
681 |
|
|
682 |
@param aDescriptor Contains the new device_qualifier descriptor.
|
|
683 |
|
|
684 |
@return KErrNone if successful.
|
|
685 |
*/
|
|
686 |
inline TInt SetDeviceQualifierDescriptor(const TDesC8& aDescriptor);
|
|
687 |
|
|
688 |
/** Copies the current other_speed_configuration descriptor into aDescriptor.
|
|
689 |
|
|
690 |
@param aDescriptor Receives the current other_speed_configuration descriptor.
|
|
691 |
|
|
692 |
@return KErrNone if successful.
|
|
693 |
*/
|
|
694 |
inline TInt GetOtherSpeedConfigurationDescriptor(TDes8& aDescriptor);
|
|
695 |
|
|
696 |
/** Sets the other_speed_configuration descriptor to the contents of aDescriptor.
|
|
697 |
|
|
698 |
@param aDescriptor Contains the new other_speed_configuration descriptor.
|
|
699 |
|
|
700 |
@return KErrNone if successful.
|
|
701 |
*/
|
|
702 |
inline TInt SetOtherSpeedConfigurationDescriptor(const TDesC8& aDescriptor);
|
|
703 |
|
|
704 |
/** Copies the class specific interface descriptor block into aInterfaceDescriptor for the interface
|
|
705 |
with alternate setting aSettingNumber, 0 for the main interface.
|
|
706 |
|
|
707 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
708 |
@param aInterfaceDescriptor Contains the interface descriptor to be set.
|
|
709 |
|
|
710 |
@return KErrNone if successful.
|
|
711 |
*/
|
|
712 |
inline TInt GetCSInterfaceDescriptorBlock(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
|
|
713 |
|
|
714 |
/** aSettingNumber is the alternate interface setting, 0 for the main interface, that the descriptor block
|
|
715 |
aDes should be attached to. aDes is a block of data containing at least one class specific descriptor
|
|
716 |
for transmission during enumeration after the class interface descriptor (or alternate interface
|
|
717 |
descriptor) has been sent, but before the endpoint descriptors belonging to this interface are sent.
|
|
718 |
aDes may contain as many descriptors as are necessary or only one. SetCSInterfaceDescriptorBlock()
|
|
719 |
should be called at any time after SetInterface() has been called to establish a main interface or an
|
|
720 |
alternate interface. More than one call may be made - the data blocks will be concatenated prior to
|
|
721 |
sending. No checking or validation of the contents of aDes will be made and it is the caller's
|
|
722 |
responsibility to ensure that the data supplied is correct and appropriate to the interface identified
|
|
723 |
by aSettingNumber.
|
|
724 |
|
|
725 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
726 |
@param aInterfaceDescriptor Contains the interface descriptor to be set.
|
|
727 |
|
|
728 |
@return KErrNone if successful.
|
|
729 |
*/
|
|
730 |
inline TInt SetCSInterfaceDescriptorBlock(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
|
|
731 |
|
|
732 |
/** Copies the size of the class specific interface descriptor block for the interface with alternate
|
|
733 |
setting aSettingNumber, 0 for the main interface, into aSize.
|
|
734 |
|
|
735 |
@param aSettingNumber The alternate setting number.
|
|
736 |
@param aSize receives the size of the interface descriptor.
|
|
737 |
|
|
738 |
@return KErrNone if successful.
|
|
739 |
*/
|
|
740 |
inline TInt GetCSInterfaceDescriptorBlockSize(TInt aSettingNumber, TInt& aSize);
|
|
741 |
|
|
742 |
/** Copies the class specific endpoint descriptor for logical endpoint number aEndpointNumber
|
|
743 |
into aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main
|
|
744 |
interface.
|
|
745 |
|
|
746 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
747 |
@param aEndpointNumber Valid endpoint number on this interface.
|
|
748 |
@param aEndpointDescriptor Receives the endpoint descriptor.
|
|
749 |
|
|
750 |
@return KErrNone if successful.
|
|
751 |
*/
|
|
752 |
inline TInt GetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
|
|
753 |
TDes8& aEndpointDescriptor);
|
|
754 |
|
|
755 |
/** Sets the class specific endpoint descriptor for logical endpoint number aEndpointNumber contained in
|
|
756 |
aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
|
|
757 |
for transmission to the host during enumeration.
|
|
758 |
|
|
759 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
760 |
@param aEndpointNumber Valid endpoint number on this interface.
|
|
761 |
@param aEndpointDescriptor Contains the endpoint descriptor to be set.
|
|
762 |
|
|
763 |
@return KErrNone if successful.
|
|
764 |
*/
|
|
765 |
inline TInt SetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
|
|
766 |
const TDesC8& aEndpointDescriptor);
|
|
767 |
|
|
768 |
/** Copies the size of the class specific endpoint descriptor block for logical endpoint number
|
|
769 |
aEndpointNumber for the interface with alternate setting aSettingNumber, 0 for the main interface,
|
|
770 |
into aSize.
|
|
771 |
|
|
772 |
@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
|
|
773 |
@param aEndpointNumber Valid endpoint number on this interface.
|
|
774 |
@param aSize On return, contains the size of the class specific endpoint descriptor block.
|
|
775 |
|
|
776 |
@return KErrNone if successful.
|
|
777 |
*/
|
|
778 |
inline TInt GetCSEndpointDescriptorBlockSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
|
|
779 |
|
|
780 |
/** Generates a Remote Wakeup bus condition.
|
|
781 |
The capability of the device to generate Remote Wakeup signalling is enquired in
|
|
782 |
RDevUsbcClient::DeviceCaps.
|
|
783 |
|
|
784 |
@return KErrNone if this signalling is possible and the signal has been generated.
|
|
785 |
*/
|
|
786 |
inline TInt SignalRemoteWakeup();
|
|
787 |
|
|
788 |
/** Simulates a physical removal of the USB cable by disabling the D+/- pull-ups.The iConnect member of
|
|
789 |
TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(), indicates whether this functionality is
|
|
790 |
supported.
|
|
791 |
|
|
792 |
@return KErrNone if successful.
|
|
793 |
*/
|
|
794 |
inline TInt DeviceDisconnectFromHost();
|
|
795 |
|
|
796 |
/** Simulates a physical insertion of the USB cable by enabling the D+/- pull-ups.The iConnect member
|
|
797 |
of TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(), indicates whether this functionality
|
|
798 |
is supported.
|
|
799 |
|
|
800 |
@return KErrNone if successful.
|
|
801 |
*/
|
|
802 |
inline TInt DeviceConnectToHost();
|
|
803 |
|
|
804 |
/** Powers up the UDC and connects it to the bus if one or more interfaces exist.
|
|
805 |
|
|
806 |
@return KErrNone if UDC successfully powered up, KErrNotReady if no
|
|
807 |
interfaces have been registered yet, KErrHardwareNotAvailable if UDC
|
|
808 |
couldn't be activated.
|
|
809 |
*/
|
|
810 |
inline TInt PowerUpUdc();
|
|
811 |
|
|
812 |
/** Enquires about the current operating speed of the UDC.
|
|
813 |
|
|
814 |
@return ETrue if the UDC is currently operating at High speed, EFalse otherwise.
|
|
815 |
*/
|
|
816 |
inline TBool CurrentlyUsingHighSpeed();
|
|
817 |
|
|
818 |
/** Allocates the use of aResource to aEndpoint. It will be used from when the current bus transfer has been
|
|
819 |
completed.
|
|
820 |
|
|
821 |
@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
|
|
822 |
behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
|
|
823 |
@param aEndpoint The endpoint number to which the resource is to be allocated.
|
|
824 |
|
|
825 |
@return KErrNone if successful, KErrInUse if the resource is already consumed and cannot be allocated,
|
|
826 |
KErrNotSupported if the endpoint does not support the resource requested.
|
|
827 |
|
|
828 |
@publishedPartner @deprecated
|
|
829 |
*/
|
|
830 |
inline TInt AllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
|
|
831 |
|
|
832 |
/** Deallocates the use of aResource aEndpoint or ends a specified endpoint behaviour.
|
|
833 |
|
|
834 |
@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
|
|
835 |
behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
|
|
836 |
@param aEndpoint The endpoint number from which the resource is to be removed.
|
|
837 |
|
|
838 |
@return KErrNone if the resource has been successfully deallocated, KErrNotSupported if the endpoint
|
|
839 |
does not support the resource requested.
|
|
840 |
|
|
841 |
@publishedPartner @deprecated
|
|
842 |
*/
|
|
843 |
inline TInt DeAllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
|
|
844 |
|
|
845 |
/** Queries endpoint resource use.
|
|
846 |
|
|
847 |
@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
|
|
848 |
behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
|
|
849 |
@param aEndpoint The endpoint number at which the resource is to be queried.
|
|
850 |
|
|
851 |
@return ETrue is the specified resource is in use at the endpoint and EFalse if not.
|
|
852 |
*/
|
|
853 |
inline TBool QueryEndpointResourceUse(TInt aEndpoint, TUsbcEndpointResource aResource);
|
|
854 |
|
|
855 |
/** Request (i.e. claim for this channel) up to five endpoints and set the class type for this USB
|
|
856 |
interface. 'aInterfaceData' is a package buffer which describes the interface and all the endpoints
|
|
857 |
being requested by the driver for this interface.
|
|
858 |
|
|
859 |
@param aInterfaceNumber Distinguishes between alternate interfaces. If these are not be used then this
|
|
860 |
should always be zero. If this parameter is used, then its value must be one more than that of the
|
|
861 |
proceeding alternate interface.
|
|
862 |
@param aInterfaceData A package buffer which describes the interface and all the endpoints being
|
|
863 |
requested by the driver for this interface.
|
|
864 |
|
|
865 |
|
|
866 |
@return KErrInUse if any of the endpoints being requested have already been claimed by another channel.
|
|
867 |
KErrNotSupported if an endpoint with all of the specified properties is not supported on this
|
|
868 |
platform. KErrNoMemory if insufficient memory is available to complete the operation.
|
|
869 |
*/
|
|
870 |
inline TInt SetInterface(TInt aInterfaceNumber, TUsbcScInterfaceInfoBuf& aInterfaceData);
|
|
871 |
|
|
872 |
|
|
873 |
/**
|
|
874 |
This method should be called after SetInterface has been called for all possible alternative settings.
|
|
875 |
Calling this invalidates further calls to SetInterface. On success, a chunk handle is created and
|
|
876 |
passed back though aChunk. This is needed for the user side to access the shared chunk where the
|
|
877 |
data is stored. Note that if you are using the BIL (described later), then FinalizeInterface (...)
|
|
878 |
should be used instead, which will call this method.
|
|
879 |
|
|
880 |
@return KErrNone on successful completion, or one of the system wide error codes.
|
|
881 |
*/
|
|
882 |
inline TInt RealizeInterface(RChunk& aChunk);
|
|
883 |
|
|
884 |
|
|
885 |
/** Release an interface previously claimed by this channel. Alternate interfaces need to be released
|
|
886 |
in strict descending order, starting with the last (i.e. highest numbered) one.
|
|
887 |
It is not necessary to release an interface that wasn't successfully requested.
|
|
888 |
|
|
889 |
@param aInterfaceNumber Specifies the alternate setting number 'aInterfaceNum' of the interface to be
|
|
890 |
released.
|
|
891 |
|
|
892 |
@return KErrNone if successful. KErrArgument if the alternate setting doesn't exist or is released out
|
|
893 |
of order.
|
|
894 |
*/
|
|
895 |
inline TInt ReleaseInterface(TInt aInterfaceNumber);
|
|
896 |
|
|
897 |
/** Copies the current string descriptor language ID (LANGID) code into the aLangId argument. Even though
|
|
898 |
the USB spec allows for the existence of a whole array of LANGID codes, we only support one.
|
|
899 |
|
|
900 |
@param aLangId Receives the LANGID code.
|
|
901 |
|
|
902 |
@return KErrNone if successful, KErrArgument if problem with argument (memory cannot be written to, etc.).
|
|
903 |
*/
|
|
904 |
inline TInt GetStringDescriptorLangId(TUint16& aLangId);
|
|
905 |
|
|
906 |
/** Sets the string descriptor language ID (LANGID). Even though the USB spec allows for the existence of
|
|
907 |
a whole array of LANGID codes, we only support one.
|
|
908 |
|
|
909 |
@param aLangId The LANGID code to be set.
|
|
910 |
|
|
911 |
@return KErrNone if successful.
|
|
912 |
*/
|
|
913 |
inline TInt SetStringDescriptorLangId(TUint16 aLangId);
|
|
914 |
|
|
915 |
/** Copies the string descriptor identified by the iManufacturer index field of the Standard Device
|
|
916 |
Descriptor into the aString argument.
|
|
917 |
|
|
918 |
@param aString Receives manufacturer string.
|
|
919 |
|
|
920 |
@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
|
|
921 |
descriptor, KErrNotFound if the string descriptor couldn't be found.
|
|
922 |
*/
|
|
923 |
inline TInt GetManufacturerStringDescriptor(TDes16& aString);
|
|
924 |
|
|
925 |
/** Sets the string descriptor identified by the iManufacturer index field of the Standard Device
|
|
926 |
Descriptor to the aString argument.
|
|
927 |
|
|
928 |
@param aString Contains the new manufacturer string descriptor.
|
|
929 |
|
|
930 |
@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
|
|
931 |
aString (in which case the old string descriptor will be preserved).
|
|
932 |
*/
|
|
933 |
inline TInt SetManufacturerStringDescriptor(const TDesC16& aString);
|
|
934 |
|
|
935 |
/** Removes (deletes) the string descriptor identified by the iManufacturer index field of the Standard
|
|
936 |
Device Descriptor and sets that field to zero.
|
|
937 |
|
|
938 |
@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
|
|
939 |
*/
|
|
940 |
inline TInt RemoveManufacturerStringDescriptor();
|
|
941 |
|
|
942 |
/** Retrieves the string descriptor identified by the iProduct index field of the Standard Device
|
|
943 |
Descriptor into the aString argument.
|
|
944 |
|
|
945 |
@param aString Receives product string.
|
|
946 |
|
|
947 |
@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
|
|
948 |
descriptor, KErrNotFound if the string descriptor couldn't be found.
|
|
949 |
*/
|
|
950 |
inline TInt GetProductStringDescriptor(TDes16& aString);
|
|
951 |
|
|
952 |
/** Sets the string descriptor identified by the iProduct index field of the Standard Device Descriptor to
|
|
953 |
the aString argument.
|
|
954 |
|
|
955 |
@param aString Contains the new product string descriptor.
|
|
956 |
|
|
957 |
@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
|
|
958 |
aString (in which case the old string descriptor will be preserved).
|
|
959 |
*/
|
|
960 |
inline TInt SetProductStringDescriptor(const TDesC16& aString);
|
|
961 |
|
|
962 |
/** Removes (deletes) the string descriptor identified by the iProduct index field of the Standard Device
|
|
963 |
Descriptor and sets that field to zero.
|
|
964 |
|
|
965 |
@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
|
|
966 |
*/
|
|
967 |
inline TInt RemoveProductStringDescriptor();
|
|
968 |
|
|
969 |
/** Retrieves the string descriptor identified by the iSerialNumber index field of the Standard Device
|
|
970 |
Descriptor into the aString argument.
|
|
971 |
|
|
972 |
@param aString Receives product string.
|
|
973 |
|
|
974 |
@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
|
|
975 |
descriptor, KErrNotFound if the string descriptor couldn't be found.
|
|
976 |
*/
|
|
977 |
inline TInt GetSerialNumberStringDescriptor(TDes16& aString);
|
|
978 |
|
|
979 |
/** Sets the string descriptor identified by the iSerialNumber index field of the Standard Device
|
|
980 |
Descriptor to the aString argument.
|
|
981 |
|
|
982 |
@param aString Contains the new serial number string descriptor.
|
|
983 |
|
|
984 |
@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
|
|
985 |
aString (in which case the old string descriptor will be preserved).
|
|
986 |
*/
|
|
987 |
inline TInt SetSerialNumberStringDescriptor(const TDesC16& aString);
|
|
988 |
|
|
989 |
/** Removes (deletes) the string descriptor identified by the iSerialNumber index field of the Standard
|
|
990 |
Device Descriptor and sets that field to zero.
|
|
991 |
|
|
992 |
@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
|
|
993 |
*/
|
|
994 |
inline TInt RemoveSerialNumberStringDescriptor();
|
|
995 |
|
|
996 |
/** Retrieves the string descriptor identified by the iConfiguration index field of the (first) Standard
|
|
997 |
Configuration Descriptor into the aString argument.
|
|
998 |
|
|
999 |
@param aString Receives configuration string.
|
|
1000 |
|
|
1001 |
@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
|
|
1002 |
descriptor, KErrNotFound if the string descriptor couldn't be found.
|
|
1003 |
*/
|
|
1004 |
inline TInt GetConfigurationStringDescriptor(TDes16& aString);
|
|
1005 |
|
|
1006 |
/** Sets the string descriptor identified by the iConfiguration index field of the Standard Configuration
|
|
1007 |
Descriptor to the aString argument.
|
|
1008 |
|
|
1009 |
@param aString Contains the new serial number string descriptor.
|
|
1010 |
|
|
1011 |
@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
|
|
1012 |
aString (in which case the old string descriptor will be preserved).
|
|
1013 |
*/
|
|
1014 |
inline TInt SetConfigurationStringDescriptor(const TDesC16& aString);
|
|
1015 |
|
|
1016 |
/** Removes (deletes) the string descriptor identified by the iConfiguration index field of the Standard
|
|
1017 |
Configuration Descriptor and sets that field to zero.
|
|
1018 |
|
|
1019 |
@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
|
|
1020 |
*/
|
|
1021 |
inline TInt RemoveConfigurationStringDescriptor();
|
|
1022 |
|
|
1023 |
/** Copies the string of the USB string descriptor at the specified index in the string descriptor array
|
|
1024 |
into the aString argument.
|
|
1025 |
|
|
1026 |
Although this function can also be used for it, for querying most standard string descriptors
|
|
1027 |
there exists a set of dedicated access functions.
|
|
1028 |
|
|
1029 |
@see RDevUsbcClient::GetStringDescriptorLangId
|
|
1030 |
@see RDevUsbcClient::GetManufacturerStringDescriptor
|
|
1031 |
@see RDevUsbcClient::GetProductStringDescriptor
|
|
1032 |
@see RDevUsbcClient::GetSerialNumberStringDescriptor
|
|
1033 |
@see RDevUsbcClient::GetConfigurationStringDescriptor
|
|
1034 |
|
|
1035 |
@param aIndex The position of the string descriptor in the string descriptor array.
|
|
1036 |
@param aString The target location for the string descriptor copy.
|
|
1037 |
|
|
1038 |
@return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index,
|
|
1039 |
KErrArgument if MaxLength() of aString is too small to hold the entire descriptor.
|
|
1040 |
*/
|
|
1041 |
inline TInt GetStringDescriptor(TUint8 aIndex, TDes16& aString);
|
|
1042 |
|
|
1043 |
/** Sets the aString argument to be the string of a USB string descriptor at the specified index in the
|
|
1044 |
string descriptor array. If a string descriptor already exists at that position then its string will
|
|
1045 |
be replaced.
|
|
1046 |
|
|
1047 |
Care should be taken, when choosing aIndex, not to inadvertently overwrite one of the standard
|
|
1048 |
string descriptors. For their manipulation there exists a set of dedicated access functions.
|
|
1049 |
|
|
1050 |
@see RDevUsbcClient::SetStringDescriptorLangId
|
|
1051 |
@see RDevUsbcClient::SetManufacturerStringDescriptor
|
|
1052 |
@see RDevUsbcClient::SetProductStringDescriptor
|
|
1053 |
@see RDevUsbcClient::SetSerialNumberStringDescriptor
|
|
1054 |
@see RDevUsbcClient::SetConfigurationStringDescriptor
|
|
1055 |
|
|
1056 |
@param aIndex The position of the string descriptor in the string descriptor array.
|
|
1057 |
@param aString Contains the string descriptor to be set.
|
|
1058 |
|
|
1059 |
@return KErrNone if successful, KErrArgument if aIndex is invalid, KErrNoMemory if no memory
|
|
1060 |
is available to store the new string (an existing descriptor at that index will be preserved).
|
|
1061 |
*/
|
|
1062 |
inline TInt SetStringDescriptor(TUint8 aIndex, const TDesC16& aString);
|
|
1063 |
|
|
1064 |
/** Removes (deletes) the USB string descriptor at the specified index in the string descriptor array.
|
|
1065 |
The position in the array of other string descriptors is not affected.
|
|
1066 |
|
|
1067 |
Care should be taken, when choosing aIndex, not to inadvertently delete a standard string descriptor
|
|
1068 |
(also because index references from non-string descriptors would be invalidated). For the deletion
|
|
1069 |
of most standard string descriptors there exists a set of dedicated functions.
|
|
1070 |
|
|
1071 |
@see RDevUsbcClient::RemoveManufacturerStringDescriptor
|
|
1072 |
@see RDevUsbcClient::RemoveProductStringDescriptor
|
|
1073 |
@see RDevUsbcClient::RemoveSerialNumberStringDescriptor
|
|
1074 |
@see RDevUsbcClient::RemoveConfigurationStringDescriptor
|
|
1075 |
|
|
1076 |
@param aIndex The position of the string descriptor in the string descriptor array.
|
|
1077 |
|
|
1078 |
@return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index.
|
|
1079 |
*/
|
|
1080 |
inline TInt RemoveStringDescriptor(TUint8 aIndex);
|
|
1081 |
|
|
1082 |
|
|
1083 |
|
|
1084 |
/** Requests notification for when there is data available on the buffer indicated. If the buffer
|
|
1085 |
already has data in it, it will return immediately, otherwise it will block until there is.
|
|
1086 |
|
|
1087 |
If the BIL methods are being used (recommended), then this method should not be called directly,
|
|
1088 |
using TEndpointBuffer::GetBuffer instead.
|
|
1089 |
|
|
1090 |
@param aBufferNumber Indicates the buffer for which the caller wishes to know about data
|
|
1091 |
additions. The buffer needed of any given endpoint can be found by inspecting the alternative
|
|
1092 |
setting table, in the chunk header. The location of the buffer can be found by looking at the
|
|
1093 |
buffer offset table, also in the chunk header.
|
|
1094 |
|
|
1095 |
@param aStatus The request status where notification of completion is directed. KErrCancel is
|
|
1096 |
returned if the asynchronous operation was cancelled.
|
|
1097 |
|
|
1098 |
@param aLength A preference for the quantity of data to be read. This value is only a
|
|
1099 |
suggestion and my be ignored. The default value of 0 indicates no preference.
|
|
1100 |
|
|
1101 |
@return KErrNone on success, or KErrArgument if the buffer number is invalid.
|
|
1102 |
*/
|
|
1103 |
inline TInt ReadDataNotify(TInt aBufferNumber, TRequestStatus& aStatus, TInt aLength=0);
|
|
1104 |
|
|
1105 |
|
|
1106 |
/** Requests the LDD to write the contents of the given buffer to the USB hardware. Notification is
|
|
1107 |
given when this is complete. More then one write request can be queued on any one endpoint, to allow
|
|
1108 |
for less Hardware idling between buffers.
|
|
1109 |
|
|
1110 |
If the BIL methods are being used (recommended), then this method should not be called directly,
|
|
1111 |
using TEndpointBuffer::WriteBuffer instead.
|
|
1112 |
|
|
1113 |
@param aBufferNumber represents the buffer number of the buffer of which the caller has placed the
|
|
1114 |
data. As described with ReadDataNotify(...), details of the buffers can be found in the chunk header.
|
|
1115 |
|
|
1116 |
@param aStart Represents the start offset of the data within the chunk. This start location must be
|
|
1117 |
aligned to a multiple of the maximum packet size for the endpoint, so that the data can be DMAed
|
|
1118 |
straight out of the buffer.
|
|
1119 |
|
|
1120 |
@param aLength Represents the amount of data to be sent to the host in bytes.
|
|
1121 |
|
|
1122 |
@param aFlags Is a bitfield, where bit 0 should be set if a ZLP is to be sent to the host after the
|
|
1123 |
current transaction. All other bits are reserved for future use.
|
|
1124 |
*/
|
|
1125 |
inline void WriteData(TInt aBufferNumber, TUint aStart, TUint aLength, TUint aFlags, TRequestStatus& aStatus);
|
|
1126 |
|
|
1127 |
|
|
1128 |
|
|
1129 |
/** Cancels an outstanding read request on endpoint buffer aBufferNumber.
|
|
1130 |
|
|
1131 |
@param aBufferNumber The endpoint buffer number whose read is to be cancelled.
|
|
1132 |
*/
|
|
1133 |
inline void ReadCancel(TInt aBufferNumber);
|
|
1134 |
|
|
1135 |
|
|
1136 |
/** Cancels an outstanding write request on endpoint buffer aBufferNumber.
|
|
1137 |
|
|
1138 |
@param aBufferNumber The endpoint buffer number whose write is to be cancelled.
|
|
1139 |
*/
|
|
1140 |
inline void WriteCancel(TInt aBufferNumber);
|
|
1141 |
|
|
1142 |
/** Cancels any transfer on any endpoint buffer specified in aBufferMask.
|
|
1143 |
|
|
1144 |
@code
|
|
1145 |
// Cancel transfer requests on buffers 1, 2, 3 & 4
|
|
1146 |
usbPort.EndpointTransferCancel(1 | 2 | 4 | 8);
|
|
1147 |
@endcode
|
|
1148 |
|
|
1149 |
@param aBufferMask bitmap of the endpoint buffer numbers.
|
|
1150 |
*/
|
|
1151 |
inline void EndpointTransferCancel(TUint aBufferMask);
|
|
1152 |
|
|
1153 |
/** Register for notification when a change of the Interface alternate setting or the USB Controller's
|
|
1154 |
current state occurs. When the alternate setting or the Controller state changes, then the
|
|
1155 |
asynchronous function completes and the current alternate setting number or Controller state is
|
|
1156 |
written back to aValue. If the KUsbAlternateSetting bit is set then the remaining bits are the
|
|
1157 |
alternate setting number. Otherwise aValue is interpreted as a TUsbcDeviceState.
|
|
1158 |
|
|
1159 |
@see TUsbcDeviceState
|
|
1160 |
|
|
1161 |
@param aStatus The request status.
|
|
1162 |
@param aValue Receives the alternate setting number or Controller state.
|
|
1163 |
*/
|
|
1164 |
inline void AlternateDeviceStatusNotify(TRequestStatus& aStatus, TUint& aValue);
|
|
1165 |
|
|
1166 |
/** Completes an AlternateDeviceStatusNotify request. If a request has previously been made then the
|
|
1167 |
status variable is updated with the current device state.
|
|
1168 |
*/
|
|
1169 |
inline void AlternateDeviceStatusNotifyCancel();
|
|
1170 |
|
|
1171 |
/** If the channel has changed the grouping of endpoints between interfaces or changed the interface class
|
|
1172 |
type from the defaults then it is necessary to force a re-enumeration. This will typically involve the
|
|
1173 |
Symbian OS device initiating a disconnection and re-connection. This is an asynchronous operation
|
|
1174 |
which will complete when the Controller is successfully configured by the host, i.e. has achieved
|
|
1175 |
EUsbcDeviceStateConfigured. Since it is not known if the operation has failed, at the same time that
|
|
1176 |
a ReEnumerate request is made, a timer should be set up to complete after approximately 5 seconds. It
|
|
1177 |
can be assumed that if the operation has not completed after this time interval then it will not
|
|
1178 |
complete.
|
|
1179 |
|
|
1180 |
@param aStatus The request status.
|
|
1181 |
*/
|
|
1182 |
inline void ReEnumerate(TRequestStatus& aStatus);
|
|
1183 |
|
|
1184 |
/** Cancels an outstanding ReEnumerate() request.
|
|
1185 |
*/
|
|
1186 |
inline void ReEnumerateCancel();
|
|
1187 |
|
|
1188 |
/** Register for notification when a change in stall status of any of the interface's endpoints occurs,
|
|
1189 |
but not ep0. When a change in stall status occurs, then the asynchronous function completes and the
|
|
1190 |
current stall state is written back to 'aEndpointStatus' as a bit map: Only stall state changes caused
|
|
1191 |
by SET_FEATURE and CLEAR_FEATURE standard commands on ep0 will be notified when this function
|
|
1192 |
completes. After this request completes the request should be re-issued to obtain future
|
|
1193 |
notifications.
|
|
1194 |
|
|
1195 |
@param aStatus The request status.
|
|
1196 |
@param aEndpointMask A bitmap of the endpoints' stall status. This is filled in when the call completes.
|
|
1197 |
bit 1 represents the interface's virtual endpoint 1, (KUsbcEndpoint1Bit)
|
|
1198 |
bit 2 represents the interface's virtual endpoint 2, (KUsbcEndpoint2Bit) etc.
|
|
1199 |
bit value 0 - not stalled,
|
|
1200 |
bit value 1 - stalled.
|
|
1201 |
*/
|
|
1202 |
inline void EndpointStatusNotify(TRequestStatus& aStatus, TUint& aEndpointMask);
|
|
1203 |
|
|
1204 |
/** Completes an endpoint status notify request.
|
|
1205 |
*/
|
|
1206 |
inline void EndpointStatusNotifyCancel();
|
|
1207 |
|
|
1208 |
/** Get current on-the-go features relating to the ability of device/host pair to
|
|
1209 |
perform OTG role swap.
|
|
1210 |
|
|
1211 |
@param aFeatures On return it contains features the device currently has.
|
|
1212 |
bit 2 represents b_hnp_enable, (KUsbOtgAttr_B_HnpEnable)
|
|
1213 |
bit 3 represents a_hnp_support, (KUsbOtgAttr_A_HnpSupport)
|
|
1214 |
bit 4 represents a_alt_hnp_support, (KUsbOtgAttr_A_AltHnpSupport)
|
|
1215 |
@return KErrNone if successful, KErrNotSupported if OTG is not supported by
|
|
1216 |
this device, otherwise system-wide error returns.
|
|
1217 |
*/
|
|
1218 |
inline TInt GetOtgFeatures(TUint8& aFeatures);
|
|
1219 |
|
|
1220 |
/** Register for notification on USB on-the-go features' change. If any OTG feature
|
|
1221 |
is changed, request completes and current feature value is filled in aValue.
|
|
1222 |
|
|
1223 |
@param aStatus Request status object.
|
|
1224 |
@param aValue On request completion, contains current OTG feature value.
|
|
1225 |
*/
|
|
1226 |
inline void OtgFeaturesNotify(TRequestStatus& aStatus, TUint8& aValue);
|
|
1227 |
|
|
1228 |
/** Cancel pending OTG feature request.
|
|
1229 |
*/
|
|
1230 |
inline void OtgFeaturesNotifyCancel();
|
|
1231 |
|
|
1232 |
/** This function retrieves the alternate setting that the WriteData function can
|
|
1233 |
write to. After a host sets the alternate setting, writes to the IN endpoint
|
|
1234 |
are not permitted by the LDD until this method has been called.
|
|
1235 |
This function is not asynchronous nor blocking, and should not be used to
|
|
1236 |
detect that an alternate setting has happened.
|
|
1237 |
|
|
1238 |
If the BIL methods are being used (recommended), then this method should not be called directly.
|
|
1239 |
|
|
1240 |
@return The alternative setting number or KErrInUse if the current alternative
|
|
1241 |
setting is already in use, that is to say that the alternative setting has not changed.
|
|
1242 |
*/
|
|
1243 |
inline TInt StartNextInAlternateSetting();
|
|
1244 |
|
|
1245 |
|
|
1246 |
/*******************************\
|
|
1247 |
* Buffer Interface Layer (BIL) *
|
|
1248 |
\*******************************/
|
|
1249 |
|
|
1250 |
// This following functions, as well as the ones in TEndpointBuffer (below),
|
|
1251 |
// can be considered the BIL.
|
|
1252 |
|
|
1253 |
|
|
1254 |
/**
|
|
1255 |
Finalize the interface, creating a chunk for use with reading/writing to endpoints.
|
|
1256 |
FinalizeInterface should be called after all alternate interfaces have been set up with SetInteface.
|
|
1257 |
Any attempt to call SetInterface after this stage will fail.
|
|
1258 |
|
|
1259 |
@return KErrNone if operation is successfull
|
|
1260 |
System wide error codes if chunk creation failed
|
|
1261 |
*/
|
|
1262 |
IMPORT_C TInt FinalizeInterface();
|
|
1263 |
|
|
1264 |
/**
|
|
1265 |
Finalize the interface, creating a chunk for use with reading/writing to endpoints. This
|
|
1266 |
version of the method provides a handle to the chunk, which is needed if the
|
|
1267 |
buffer is to be passed and used by other processes.
|
|
1268 |
FinalizeInterface should be called after all alternate interfaces have been set up with SetInteface.
|
|
1269 |
Any attempt to call SetInterface after this stage will fail.
|
|
1270 |
|
|
1271 |
@param aChunk On success aChunk points to the created chunk.
|
|
1272 |
@return KErrNone if operation is successfull
|
|
1273 |
System wide error codes if chunk creation failed
|
|
1274 |
*/
|
|
1275 |
IMPORT_C TInt FinalizeInterface(RChunk*& aChunk);
|
|
1276 |
|
|
1277 |
/**
|
|
1278 |
Opens an endpoint, an endpoint should be opened before any operations are attempted on it.
|
|
1279 |
|
|
1280 |
@param aEpB On success aEpB will be filled with the relevant details for that endpoint
|
|
1281 |
@param aEpI endpoint number to be opened
|
|
1282 |
@return KErrNone if operation is successfull
|
|
1283 |
KErrNotFound if endpoint number is not valid for current alternate setting
|
|
1284 |
KErrInUse if endpoint is already opened
|
|
1285 |
KErrArgument if endpoint buffer argument passed is already in existence and being used
|
|
1286 |
*/
|
|
1287 |
IMPORT_C TInt OpenEndpoint(TEndpointBuffer & aEpB, TInt aEpI);
|
|
1288 |
|
|
1289 |
/**
|
|
1290 |
Switches to processing from one Alternate setting to the next. All open endpoints (except EP0) must
|
|
1291 |
be close before this can be called.
|
|
1292 |
|
|
1293 |
@param aFlush If ETrue, the method will purge the buffers of any data unread for the old setting.
|
|
1294 |
If each endpoint was not read up until KErrEof was reached, then this should be set.
|
|
1295 |
|
|
1296 |
@return the alternate Setting if operation is successful
|
|
1297 |
KErrInUse if any endpoints in present alternate setting is still open (except Ep0)
|
|
1298 |
KErrNotReady if there is no change in alternate setting
|
|
1299 |
KErrInUse if StartNextInAlternateSetting detects no change in alternate setting.
|
|
1300 |
KErrCorrupt if the buffer structure becomes corrupt.
|
|
1301 |
*/
|
|
1302 |
IMPORT_C TInt StartNextOutAlternateSetting(TBool aFlush);
|
|
1303 |
|
|
1304 |
/**
|
|
1305 |
Sets aChunk to RChunk currently in use by BIL.
|
|
1306 |
|
|
1307 |
@param aChunk aChunk will point to RChunk currently in use by BIL
|
|
1308 |
@return KErrNone on success otherwise a system wide error code, if an error has occurred.
|
|
1309 |
*/
|
|
1310 |
IMPORT_C TInt GetDataTransferChunk(RChunk*& aChunk);
|
189
|
1311 |
/**
|
|
1312 |
Call this function to reset alternate setting related data to initial state,
|
|
1313 |
this API should be called when device state goes to undefined.
|
|
1314 |
*/
|
|
1315 |
IMPORT_C void ResetAltSetting();
|
|
1316 |
|
|
1317 |
|
0
|
1318 |
|
|
1319 |
private:
|
189
|
1320 |
/** @internalTechnology */
|
|
1321 |
TInt Empty(TUint aBufferOffset);
|
0
|
1322 |
/** @internalTechnology */
|
|
1323 |
TInt Drain(TUint aBuffer);
|
|
1324 |
/** @internalTechnology */
|
|
1325 |
TInt Peek(TUint aBuffer);
|
|
1326 |
/** @internalTechnology */
|
|
1327 |
TInt FindNextAlternateSetting();
|
|
1328 |
|
|
1329 |
private:
|
|
1330 |
TUint8 iEndpointStatus; /** @internalTechnology Each bit corresponds to each endpoint's open/close status. */
|
|
1331 |
RChunk iSharedChunk; /** @internalTechnology The shared chunk in use. */
|
|
1332 |
TInt iAltSettingSeq; /** @internalTechnology Used to track alternate setting changes. */
|
|
1333 |
TInt iAlternateSetting; /** @internalTechnology The alternate setting used by OUT endpoints, which may lag that of IN endpoints. */
|
|
1334 |
TInt iNewAltSetting; /** @internalTechnology Used to track the next alternate setting change on OUT endpoints,
|
|
1335 |
during transition from one to the next. */
|
|
1336 |
TInt iInAltSetting; /** @internalTechnology The alternate setting used by IN endpoints, which may be ahead of OUT endpoints. */
|
|
1337 |
|
|
1338 |
|
|
1339 |
friend class TEndpointBuffer;
|
|
1340 |
#endif // #ifndef __KERNEL_MODE__
|
|
1341 |
};
|
|
1342 |
|
|
1343 |
#ifndef __KERNEL_MODE__
|
|
1344 |
|
|
1345 |
|
|
1346 |
/**
|
|
1347 |
This class forms part of the Buffer Interface Layer (BIL), which forms the
|
|
1348 |
user side component of the USB Shared Chunk Client. Objects of this type
|
|
1349 |
represent the shared chunk buffer, for a given endpoint.
|
|
1350 |
The method RDevUsbcScClient::OpenEndpoint() should be used to initialise
|
|
1351 |
objects of this type.
|
|
1352 |
*/
|
|
1353 |
class TEndpointBuffer
|
|
1354 |
{
|
|
1355 |
public:
|
|
1356 |
|
|
1357 |
/**
|
|
1358 |
This return value used by GetBuffer indicates that the item pointed to by
|
|
1359 |
aBuffer/aOffset represents a state change, instead of endpoint data.
|
|
1360 |
*/
|
|
1361 |
const static TInt KStateChange = 0x01;
|
|
1362 |
|
|
1363 |
public:
|
|
1364 |
IMPORT_C TEndpointBuffer();
|
|
1365 |
|
|
1366 |
/**
|
|
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.
|
|
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
|
|
1369 |
with new data.
|
|
1370 |
@param aBuffer aBuffer will point to data location in shared chunk
|
|
1371 |
@param aSize aSize will hold the number of valid bytes that can be read
|
|
1372 |
@param aZLP aZLP will indicate whether its a short packet or not
|
|
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
|
|
1374 |
asynchronous call ReadDataNotify to return
|
|
1375 |
@param aLength Not used at the moment
|
|
1376 |
@return KErrCompletion if operation is successfull and data is available in the buffer
|
|
1377 |
KErrNone if no data is available to be read
|
|
1378 |
KErrEof if alternate setting has changed
|
|
1379 |
KErrAccessDenied if endpoint is not opened
|
|
1380 |
KErrNotSupported if its an IN endpoint
|
|
1381 |
TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
|
|
1382 |
*/
|
|
1383 |
IMPORT_C TInt GetBuffer(TAny*& aBuffer,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
|
|
1384 |
|
|
1385 |
/**
|
|
1386 |
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.
|
|
1387 |
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
|
|
1388 |
with new data.
|
|
1389 |
@param aOffset aOffset will point to data offset in shared chunk
|
|
1390 |
@param aSize aSize will hold the number of valid bytes that can be read
|
|
1391 |
@param aZLP aZLP will indicate whether its a short packet or not
|
|
1392 |
@param aStatus In case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for
|
|
1393 |
asynchronous call ReadDataNotify to return
|
|
1394 |
@param aLength Not used at the moment
|
|
1395 |
@return KErrCompletion if operation is successfull and data is available in the buffer
|
|
1396 |
KErrNone if no data is available to be read
|
|
1397 |
KErrEof if alternate setting has changed
|
|
1398 |
KErrAccessDenied if endpoint is not opened
|
|
1399 |
KErrNotSupported if its an IN endpoint
|
|
1400 |
TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
|
|
1401 |
*/
|
|
1402 |
inline TInt GetBuffer(TUint& aOffset,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
|
|
1403 |
|
|
1404 |
/**
|
|
1405 |
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
|
|
1406 |
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.
|
|
1407 |
@param aBuffer aBuffer will point to data location in shared chunk
|
|
1408 |
@param aSize aSize will hold the number of valid bytes that can be read
|
|
1409 |
@param aZLP aZLP will indicate whether its a short packet or not
|
|
1410 |
@param aStatus In case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for
|
|
1411 |
asynchronous call ReadDataNotify to return
|
|
1412 |
@param aLength Not used at the moment
|
|
1413 |
@return KErrCompletion if operation is successfull and data is available in the buffer
|
|
1414 |
KErrNone if no data is available to be read
|
|
1415 |
KErrEof if alternate setting has changed
|
|
1416 |
KErrAccessDenied if endpoint is not opened
|
|
1417 |
KErrNotSupported if its an IN endpoint
|
|
1418 |
TEndpointBuffer::KStateChange if the returned data represents a state change (Ep0 only)
|
|
1419 |
*/
|
|
1420 |
IMPORT_C TInt TakeBuffer(TAny*& aBuffer,TUint& aSize,TBool& aZLP,TRequestStatus& aStatus,TUint aLength=0);
|
|
1421 |
|
|
1422 |
/**
|
|
1423 |
Used in conjunction with TakeBuffer method. This will make the 'oldest' block of data previously read out using the TakeBuffer method, but not
|
|
1424 |
already expired, to be released back to the system. This block can then be overwritten with new data, when it becomes available.
|
|
1425 |
@return KErrNotSupported if its an IN endpoint
|
|
1426 |
KErrNone if iTail is successfully bumped to the next transfer to be read
|
|
1427 |
*/
|
|
1428 |
|
|
1429 |
IMPORT_C TInt Expire();
|
|
1430 |
|
|
1431 |
/**
|
|
1432 |
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
|
|
1433 |
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
|
|
1434 |
ensure to expire all blocks in a timely manner to prevent the system from running out of usable memory.
|
|
1435 |
@param aAddress aAddress is the start address of the block of data previously read by the user which can be overwritten.
|
|
1436 |
@return KErrNotSupported if its an IN endpoint
|
|
1437 |
KErrNone if iTail is successfully bumped to the next transfer to be read
|
|
1438 |
KErrNotFound if a 'transfer' with start address of the data block is aAddress is not found
|
|
1439 |
*/
|
|
1440 |
|
|
1441 |
IMPORT_C TInt Expire(TAny* aAddress);
|
|
1442 |
|
|
1443 |
/**
|
|
1444 |
Initiates write operation.
|
|
1445 |
@param aBuffer aBuffer will point to data in shared chunk to be written out. aBuffer should be aligned
|
|
1446 |
@param aSize aSize will hold the number of valid bytes to be written out
|
|
1447 |
@param aZLP aZLP will indicate whether a ZLP should be transmitted after writing the data out
|
|
1448 |
@param aStatus This is an asynchronous function and user side should wait on status to know the end of write operation
|
|
1449 |
@return KErrNone if a write is successfully queued
|
|
1450 |
KErrEof if an alternate setting change has occurred, ending this endpoint.
|
|
1451 |
KErrNotSupported if its an OUT endpoint
|
|
1452 |
KErrAccessDenied if endpoint is not opened, or if buffer is out of range
|
|
1453 |
*/
|
|
1454 |
IMPORT_C TInt WriteBuffer(TAny* aBuffer,TUint aSize,TBool aZLP,TRequestStatus& aStatus);
|
|
1455 |
|
|
1456 |
/**
|
|
1457 |
Initiates write operation.
|
|
1458 |
@param aOffset aOffset will point to offset of data in shared chunk to be written out.
|
|
1459 |
@param aSize aSize will hold the number of valid bytes to be written out
|
|
1460 |
@param aZLP aZLP will indicate whether a ZLP should be transmitted after writing the data out
|
|
1461 |
@param aStatus This is an asynchronous function and user side should wait on status to know the end of write operation
|
|
1462 |
@return KErrNone if a write is successfully queued
|
|
1463 |
KErrEof if an alternate setting change has occurred, ending this endpoint.
|
|
1464 |
KErrNotSupported if its an OUT endpoint
|
|
1465 |
KErrAccessDenied if endpoint is not opened, or if buffer is out of range
|
|
1466 |
*/
|
|
1467 |
IMPORT_C TInt WriteBuffer(TUint aOffset,TUint aSize,TBool aZLP,TRequestStatus& aStatus);
|
|
1468 |
/**
|
|
1469 |
For IN endpoints, this method retrieves the geometry for the buffer, for which the
|
|
1470 |
caller should stay within, when using the WriteBuffer method.
|
|
1471 |
|
|
1472 |
@param aStart A pointer, which is set to point to the start of the buffer.
|
|
1473 |
@param aSize An TUint for which the size (in bytes) of buffer, is written into.
|
|
1474 |
|
|
1475 |
@returns KErrNotSupported if the object is on an open IN endpoint,
|
|
1476 |
otherwise it KErrNone is returned on success.
|
|
1477 |
*/
|
|
1478 |
IMPORT_C TInt GetInBufferRange(TAny*& aStart, TUint& aSize);
|
|
1479 |
|
|
1480 |
/**
|
|
1481 |
For IN endpoints, this method retrieves the geometry for the buffer, for which the
|
|
1482 |
caller should stay within, when using the WriteBuffer method.
|
|
1483 |
|
|
1484 |
@param aStart A TUint for which the buffer's start offset from the start of the chunk,
|
|
1485 |
in written into.
|
|
1486 |
@param aSize An TUint for which the size (in bytes) of buffer, is written into.
|
|
1487 |
|
|
1488 |
@returns KErrNotSupported if the object is on an open IN endpoint,
|
|
1489 |
otherwise it KErrNone is returned on success.
|
|
1490 |
*/
|
|
1491 |
IMPORT_C TInt GetInBufferRange(TUint& aStart, TUint& aSize);
|
|
1492 |
|
|
1493 |
/**
|
|
1494 |
This method closes the endpoint, after it was opened with
|
|
1495 |
RDevUsbcScClient::OpenEndpoint(...).
|
|
1496 |
No method of this object can be used after this call, until
|
|
1497 |
RDevUsbcScClient::OpenEndpoint(...) is called on it again.
|
|
1498 |
|
|
1499 |
@return KErrNone on success, otherwise KErrNotFound, if the current object is not open.
|
|
1500 |
*/
|
|
1501 |
IMPORT_C TInt Close();
|
|
1502 |
|
|
1503 |
IMPORT_C void Dump();
|
|
1504 |
|
|
1505 |
/**
|
|
1506 |
Used to retrieve the endpoint number for which this object was open on.
|
|
1507 |
|
|
1508 |
@returns the endpoint number opened by this object.
|
|
1509 |
*/
|
|
1510 |
inline TInt GetEndpointNumber();
|
|
1511 |
|
189
|
1512 |
inline TInt BufferNumber();
|
|
1513 |
|
0
|
1514 |
private:
|
|
1515 |
/** @internalTechnology */
|
|
1516 |
void Construct(RDevUsbcScClient* aClient, TUint8* aBaseAddr, const TUsbcScHdrEndpointRecord* aEpType,
|
|
1517 |
TInt aEndpointNumber, SUsbcScBufferHeader* aEndpointHdr=NULL);
|
|
1518 |
|
|
1519 |
private:
|
|
1520 |
enum TDir {EValid = KErrNone, ENotValid = KErrNotSupported, EEOF = KErrEof};
|
|
1521 |
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 */
|
|
1522 |
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 */
|
|
1523 |
TInt iEndpointNumber; /** @internalTechnology associated endpoint number */
|
|
1524 |
TInt iBufferNum; /** @internalTechnology buffer number within shared chunk */
|
|
1525 |
RDevUsbcScClient *iClient; /** @internalTechnology Parent RDevUsbcScClient object */
|
|
1526 |
TUint iBaseAddr; /** @internalTechnology The address of the beginning of the Ldd's chunk */
|
|
1527 |
|
|
1528 |
SUsbcScBufferHeader* iEndpointHdr; /** @internalTechnology Pointer to the buffer Header for OUT/BI endpoints */
|
|
1529 |
TUint8* iBufferStartAddr; /** @internalTechnology IN/BI endpoint buffer start address within shared chunk */
|
|
1530 |
TUint iSize; /** @internalTechnology IN/BI endpoint buffer size within shared chunk */
|
|
1531 |
friend class RDevUsbcScClient;
|
|
1532 |
};
|
|
1533 |
|
|
1534 |
/**
|
|
1535 |
This class can be used to retrieve the geometry of the structures
|
|
1536 |
within a shared chunk, as used by RDevUsbcScClient.
|
|
1537 |
|
|
1538 |
@see RDevUsbcScClient
|
|
1539 |
*/
|
|
1540 |
|
|
1541 |
class TUsbcScChunkHeader
|
|
1542 |
{
|
|
1543 |
public:
|
|
1544 |
/**
|
|
1545 |
The constructor for the TUsbcScChunkHeader class takes a RChunk object,
|
|
1546 |
containing USBcSc data structures, and initialises itself, so that
|
|
1547 |
GetNumberOfEndpoints & GetBuffer can be used to interpret the chunk structures.
|
|
1548 |
|
|
1549 |
@param An RChunk object, which represents an shared chunk, containing the
|
|
1550 |
USBcSc data structures to be retrieved.
|
|
1551 |
*/
|
|
1552 |
IMPORT_C TUsbcScChunkHeader(RChunk aChunk);
|
|
1553 |
/**
|
|
1554 |
Retrieves the available information in the chunk, about the given endpoint,
|
|
1555 |
on the given alternate setting. The returned TUsbcScBufferRecord,
|
|
1556 |
represents the buffer geometry, used for for the endpoint, while
|
|
1557 |
the filled in TUsbcScHdrEndpointRecord represents additional endpoint
|
|
1558 |
information.
|
|
1559 |
|
|
1560 |
@param aAltSetting The alternate setting, for which the provided endpoint number, is a member of.
|
|
1561 |
@param aEndpoint The endpoint, who's buffer geometry is required.
|
|
1562 |
@param aEndpointInf The provided record is filled in with details of the endpoint, who's number was given.
|
|
1563 |
*/
|
|
1564 |
IMPORT_C TUsbcScBufferRecord* GetBuffer(TInt aAltSetting, TInt aEndpoint, TUsbcScHdrEndpointRecord*& aEndpointInf);
|
|
1565 |
/**
|
|
1566 |
Retrieves the number of endpoints found in a given alternate setting.
|
|
1567 |
@param aAltSetting The alternate setting number, for which the number of endpoints contained within, is needed.
|
|
1568 |
*/
|
|
1569 |
IMPORT_C TInt GetNumberOfEndpoints(TInt aAltSetting);
|
|
1570 |
|
|
1571 |
public:
|
|
1572 |
TUsbcScChunkBuffersHeader* iBuffers; /** A pointer to the TUsbcScChunkBuffersHeader object, within the chunk header */
|
|
1573 |
TUsbcScChunkAltSettingHeader* iAltSettings; /** A pointer to the TUsbcScChunkAltSettingHeader object, within the chunk header */
|
|
1574 |
private:
|
|
1575 |
RChunk iChunk;
|
|
1576 |
};
|
|
1577 |
|
|
1578 |
#endif
|
|
1579 |
|
|
1580 |
#include <d32usbcsc.inl>
|
|
1581 |
|
|
1582 |
#endif // __D32USBCSC_H__
|