os/kernelhwsrv/kernel/eka/include/d32usbc.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32/include/d32usbc.h
sl@0
    15
// User side class definitions for USB Device support.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file d32usbc.h
sl@0
    21
 @publishedPartner
sl@0
    22
 @released
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef __D32USBC_H__
sl@0
    26
#define __D32USBC_H__
sl@0
    27
sl@0
    28
#include <e32ver.h>
sl@0
    29
#include <usb.h>
sl@0
    30
#include <d32usbcshared.h>
sl@0
    31
sl@0
    32
sl@0
    33
sl@0
    34
/** @internalComponent
sl@0
    35
*/
sl@0
    36
enum TTransferType
sl@0
    37
	{
sl@0
    38
	ETransferTypeReadData,
sl@0
    39
	ETransferTypeReadPacket,
sl@0
    40
	ETransferTypeWrite,
sl@0
    41
	ETransferTypeNone,
sl@0
    42
	ETransferTypeReadOneOrMore,
sl@0
    43
	ETransferTypeReadUntilShort
sl@0
    44
	};
sl@0
    45
sl@0
    46
sl@0
    47
/** Available endpoints. At most only these are available per interface.
sl@0
    48
*/
sl@0
    49
enum TEndpointNumber
sl@0
    50
	{
sl@0
    51
	EEndpoint0 = 0,
sl@0
    52
	EEndpoint1 = 1,
sl@0
    53
	EEndpoint2 = 2,
sl@0
    54
	EEndpoint3 = 3,
sl@0
    55
	EEndpoint4 = 4,
sl@0
    56
	EEndpoint5 = 5
sl@0
    57
	};
sl@0
    58
sl@0
    59
sl@0
    60
sl@0
    61
sl@0
    62
/** Bandwidth indicators for an Interface
sl@0
    63
sl@0
    64
	@see RDevUsbcClient::SetInterface()
sl@0
    65
*/
sl@0
    66
enum TUsbcBandwidthPriority
sl@0
    67
	{
sl@0
    68
	/** Economical OUT buffering. */
sl@0
    69
	EUsbcBandwidthOUTDefault = 0x00,
sl@0
    70
	/** More memory than Default for OUT buffering. */
sl@0
    71
	EUsbcBandwidthOUTPlus1   = 0x01,
sl@0
    72
	/** More memory than Plus1 for OUT buffering. */
sl@0
    73
	EUsbcBandwidthOUTPlus2   = 0x02,
sl@0
    74
	/** Maximum memory for OUT buffering.
sl@0
    75
		Use this value for high volume USB High-speed
sl@0
    76
		data transfers only, otherwise memory will be wasted.
sl@0
    77
	*/
sl@0
    78
	EUsbcBandwidthOUTMaximum = 0x03,
sl@0
    79
	//
sl@0
    80
	/** Economical IN buffering */
sl@0
    81
	EUsbcBandwidthINDefault  = 0x00,
sl@0
    82
	/** More memory than Default for IN buffering */
sl@0
    83
	EUsbcBandwidthINPlus1    = 0x10,
sl@0
    84
	/** More memory than Plus1 for IN buffering */
sl@0
    85
	EUsbcBandwidthINPlus2    = 0x20,
sl@0
    86
	/** Maximum memory for IN buffering.
sl@0
    87
		Use this value for high volume USB High-speed
sl@0
    88
		data transfers only, otherwise memory will be wasted.
sl@0
    89
	*/
sl@0
    90
	EUsbcBandwidthINMaximum  = 0x30
sl@0
    91
	};
sl@0
    92
sl@0
    93
sl@0
    94
sl@0
    95
sl@0
    96
sl@0
    97
sl@0
    98
sl@0
    99
/** Bit positions of endpoints.
sl@0
   100
sl@0
   101
	@see RDevUsbcClient::EndpointStatusNotify()
sl@0
   102
	@see RDevUsbcClient::EndpointTransferCancel()
sl@0
   103
sl@0
   104
	Bit position of endpoint0.
sl@0
   105
*/
sl@0
   106
const TUint KUsbcEndpoint0Bit = 1<<EEndpoint0;
sl@0
   107
/** Bit position of endpoint1.
sl@0
   108
*/
sl@0
   109
const TUint KUsbcEndpoint1Bit = 1<<EEndpoint1;
sl@0
   110
/** Bit position of endpoint2.
sl@0
   111
*/
sl@0
   112
const TUint KUsbcEndpoint2Bit = 1<<EEndpoint2;
sl@0
   113
/** Bit position of endpoint3.
sl@0
   114
*/
sl@0
   115
const TUint KUsbcEndpoint3Bit = 1<<EEndpoint3;
sl@0
   116
/** Bit position of endpoint4.
sl@0
   117
*/
sl@0
   118
const TUint KUsbcEndpoint4Bit = 1<<EEndpoint4;
sl@0
   119
/** Bit position of endpoint5.
sl@0
   120
*/
sl@0
   121
const TUint KUsbcEndpoint5Bit = 1<<EEndpoint5;
sl@0
   122
sl@0
   123
sl@0
   124
sl@0
   125
sl@0
   126
sl@0
   127
sl@0
   128
sl@0
   129
sl@0
   130
/** This must be filled in prior to a call to RDevUsbcClient::SetInterface().
sl@0
   131
*/
sl@0
   132
class TUsbcInterfaceInfo
sl@0
   133
	{
sl@0
   134
public:
sl@0
   135
	TUsbcInterfaceInfo(TInt aClass=0, TInt aSubClass=0, TInt aProtocol=0,
sl@0
   136
					   TDesC16* aString=NULL, TUint aTotalEndpoints=0);
sl@0
   137
public:
sl@0
   138
	/** The class, subclass and protocol that this interface supports. */
sl@0
   139
	TUsbcClassInfo iClass;
sl@0
   140
	/** The description string for the interface. Used to construct the interface string descriptor. */
sl@0
   141
	const TDesC16* iString;
sl@0
   142
	/** Total number of endpoints being requested (0-5). Endpoint 0 should not be included in this number. */
sl@0
   143
	TUint iTotalEndpointsUsed;
sl@0
   144
	/** Desired properties of the endpoints requested.
sl@0
   145
		Do NOT include endpoint 0.
sl@0
   146
		APIs use endpoint numbers that are offsets into this array.
sl@0
   147
	*/
sl@0
   148
	TUsbcEndpointInfo iEndpointData[KMaxEndpointsPerClient];
sl@0
   149
	/** 32 flag bits used for specifying miscellaneous Interface features.
sl@0
   150
		Currently defined are:
sl@0
   151
		- KUsbcInterfaceInfo_NoEp0RequestsPlease = 0x00000001
sl@0
   152
	*/
sl@0
   153
	TUint32 iFeatureWord;
sl@0
   154
	};
sl@0
   155
sl@0
   156
sl@0
   157
/** Package buffer for a TUsbcInterfaceInfo object.
sl@0
   158
sl@0
   159
	@see TUsbcInterfaceInfo
sl@0
   160
*/
sl@0
   161
typedef TPckgBuf<TUsbcInterfaceInfo> TUsbcInterfaceInfoBuf;
sl@0
   162
sl@0
   163
sl@0
   164
/** The user side handle to the USB client driver.
sl@0
   165
*/
sl@0
   166
class RDevUsbcClient : public RBusLogicalChannel
sl@0
   167
	{
sl@0
   168
public:
sl@0
   169
	/** @internalComponent */
sl@0
   170
	enum TVer
sl@0
   171
		{
sl@0
   172
		EMajorVersionNumber = 0,
sl@0
   173
		EMinorVersionNumber = 1,
sl@0
   174
		EBuildVersionNumber = KE32BuildVersionNumber
sl@0
   175
		};
sl@0
   176
sl@0
   177
	enum TRequest
sl@0
   178
		{
sl@0
   179
		// Positive requests.
sl@0
   180
		ERequestEp0 = 0x0,
sl@0
   181
		ERequestEp1 = EEndpoint1,
sl@0
   182
		ERequestEp2 = EEndpoint2,
sl@0
   183
		ERequestEp3 = EEndpoint3,
sl@0
   184
		ERequestEp4 = EEndpoint4,
sl@0
   185
		ERequestEp5 = EEndpoint5,
sl@0
   186
		ERequestUnused = 6,
sl@0
   187
		ERequestAlternateDeviceStatusNotify = 7,
sl@0
   188
		ERequestReEnumerate = 8,
sl@0
   189
		ERequestEndpointStatusNotify = 9,
sl@0
   190
		// The cancel TRequest's are interpreted as bitmaps. As they're not mixed
sl@0
   191
		// with the previous ones, it doesn't matter if they have the same absolute
sl@0
   192
		// value as those.
sl@0
   193
		ERequestEp0Cancel = 1<<ERequestEp0,
sl@0
   194
		ERequestEp1Cancel = 1<<ERequestEp1,
sl@0
   195
		ERequestEp2Cancel = 1<<ERequestEp2,
sl@0
   196
		ERequestEp3Cancel = 1<<ERequestEp3,
sl@0
   197
		ERequestEp4Cancel = 1<<ERequestEp4,
sl@0
   198
		ERequestEp5Cancel = 1<<ERequestEp5,
sl@0
   199
		ERequestUnusedCancel = 1<<ERequestUnused,
sl@0
   200
        ERequestAllCancel = (ERequestEp0Cancel | ERequestEp1Cancel |
sl@0
   201
							 ERequestEp2Cancel | ERequestEp3Cancel |
sl@0
   202
							 ERequestEp4Cancel | ERequestEp5Cancel |
sl@0
   203
							 ERequestUnusedCancel),
sl@0
   204
		ERequestAlternateDeviceStatusNotifyCancel = 1<<ERequestAlternateDeviceStatusNotify,
sl@0
   205
		ERequestReEnumerateCancel = 1<<ERequestReEnumerate,
sl@0
   206
		ERequestEndpointStatusNotifyCancel = 1<<ERequestEndpointStatusNotify,
sl@0
   207
        ERequestOtgFeaturesNotify = 10,
sl@0
   208
        ERequestOtgFeaturesNotifyCancel = 1<<ERequestOtgFeaturesNotify,
sl@0
   209
		};
sl@0
   210
sl@0
   211
	enum TControl
sl@0
   212
		{
sl@0
   213
		// Changing the order of these enums will break BC.
sl@0
   214
		EControlEndpointZeroRequestError,					// 0
sl@0
   215
		EControlEndpointCaps,
sl@0
   216
		EControlDeviceCaps,
sl@0
   217
		EControlGetAlternateSetting,
sl@0
   218
		EControlDeviceStatus,
sl@0
   219
		EControlEndpointStatus,
sl@0
   220
		EControlSetInterface,
sl@0
   221
		EControlReleaseInterface,
sl@0
   222
		EControlQueryReceiveBuffer,
sl@0
   223
		EControlSendEp0StatusPacket,						// 9
sl@0
   224
		//
sl@0
   225
		EControlHaltEndpoint,								// 10
sl@0
   226
		EControlClearHaltEndpoint,
sl@0
   227
		EControlSetDeviceControl,
sl@0
   228
		EControlReleaseDeviceControl,
sl@0
   229
		EControlEndpointZeroMaxPacketSizes,
sl@0
   230
		EControlSetEndpointZeroMaxPacketSize,
sl@0
   231
		EControlGetDeviceDescriptor,
sl@0
   232
		EControlSetDeviceDescriptor,
sl@0
   233
		EControlGetDeviceDescriptorSize,
sl@0
   234
		EControlGetConfigurationDescriptor,					// 19
sl@0
   235
		//
sl@0
   236
		EControlSetConfigurationDescriptor,					// 20
sl@0
   237
		EControlGetConfigurationDescriptorSize,
sl@0
   238
		EControlGetInterfaceDescriptor,
sl@0
   239
		EControlSetInterfaceDescriptor,
sl@0
   240
		EControlGetInterfaceDescriptorSize,
sl@0
   241
		EControlGetEndpointDescriptor,
sl@0
   242
		EControlSetEndpointDescriptor,
sl@0
   243
		EControlGetEndpointDescriptorSize,
sl@0
   244
		EControlGetCSInterfaceDescriptor,
sl@0
   245
		EControlSetCSInterfaceDescriptor,					// 29
sl@0
   246
		//
sl@0
   247
		EControlGetCSInterfaceDescriptorSize,				// 30
sl@0
   248
		EControlGetCSEndpointDescriptor,
sl@0
   249
		EControlSetCSEndpointDescriptor,
sl@0
   250
		EControlGetCSEndpointDescriptorSize,
sl@0
   251
		EControlSignalRemoteWakeup,
sl@0
   252
		EControlGetStringDescriptorLangId,
sl@0
   253
		EControlSetStringDescriptorLangId,
sl@0
   254
		EControlGetManufacturerStringDescriptor,
sl@0
   255
		EControlSetManufacturerStringDescriptor,
sl@0
   256
		EControlRemoveManufacturerStringDescriptor,			// 39
sl@0
   257
		//
sl@0
   258
		EControlGetProductStringDescriptor,					// 40
sl@0
   259
		EControlSetProductStringDescriptor,
sl@0
   260
		EControlRemoveProductStringDescriptor,
sl@0
   261
		EControlGetSerialNumberStringDescriptor,
sl@0
   262
		EControlSetSerialNumberStringDescriptor,
sl@0
   263
		EControlRemoveSerialNumberStringDescriptor,
sl@0
   264
		EControlGetConfigurationStringDescriptor,
sl@0
   265
		EControlSetConfigurationStringDescriptor,
sl@0
   266
		EControlRemoveConfigurationStringDescriptor,
sl@0
   267
		EControlDeviceDisconnectFromHost,					// 49
sl@0
   268
		//
sl@0
   269
		EControlDeviceConnectToHost,						// 50
sl@0
   270
		EControlDevicePowerUpUdc,
sl@0
   271
		EControlDumpRegisters,
sl@0
   272
		EControlSetInterface1,								// (not used)
sl@0
   273
		EControlAllocateEndpointResource,
sl@0
   274
		EControlDeAllocateEndpointResource,
sl@0
   275
		EControlQueryEndpointResourceUse,
sl@0
   276
		EControlGetEndpointZeroMaxPacketSize,
sl@0
   277
		EControlGetDeviceQualifierDescriptor,
sl@0
   278
		EControlSetDeviceQualifierDescriptor,				// 59
sl@0
   279
		//
sl@0
   280
		EControlGetOtherSpeedConfigurationDescriptor,		// 60
sl@0
   281
		EControlSetOtherSpeedConfigurationDescriptor,
sl@0
   282
		EControlCurrentlyUsingHighSpeed,
sl@0
   283
		EControlSetStringDescriptor,
sl@0
   284
		EControlGetStringDescriptor,
sl@0
   285
		EControlRemoveStringDescriptor,
sl@0
   286
        EControlSetOtgDescriptor,
sl@0
   287
        EControlGetOtgDescriptor,
sl@0
   288
        EControlGetOtgFeatures
sl@0
   289
		};
sl@0
   290
sl@0
   291
public:
sl@0
   292
sl@0
   293
#ifndef __KERNEL_MODE__
sl@0
   294
sl@0
   295
	/** Opens a channel.
sl@0
   296
sl@0
   297
		@param aUnit This should be 0 (zero).
sl@0
   298
sl@0
   299
		@return KErrNone if successful.
sl@0
   300
	*/
sl@0
   301
	inline TInt Open(TInt aUnit);
sl@0
   302
sl@0
   303
	inline TVersion VersionRequired() const;
sl@0
   304
sl@0
   305
	/** Stalls ep0 to signal command fault to the host.
sl@0
   306
sl@0
   307
		@return KErrNone if successful.
sl@0
   308
	*/
sl@0
   309
	inline TInt EndpointZeroRequestError();
sl@0
   310
sl@0
   311
	/** Retrieves the capabilities of all the endpoints on the device.
sl@0
   312
sl@0
   313
		Suggested use is as follows:
sl@0
   314
sl@0
   315
		@code
sl@0
   316
		TUsbcEndpointData data[KUsbcMaxEndpoints];
sl@0
   317
		TPtr8 dataPtr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
sl@0
   318
		ret = usbPort.EndpointCaps(dataPtr);
sl@0
   319
		@endcode
sl@0
   320
sl@0
   321
		@param aEpCapsBuf a descriptor encapsulating an array of TUsbcEndpointData.
sl@0
   322
sl@0
   323
		@return KErrNone if successful.
sl@0
   324
	*/
sl@0
   325
	inline TInt EndpointCaps(TDes8& aEpCapsBuf);
sl@0
   326
sl@0
   327
	/** Retrieves the capabilities of the USB device.
sl@0
   328
sl@0
   329
		@see TUsbDeviceCaps
sl@0
   330
sl@0
   331
		@param aDevCapsBuf a TUsbDeviceCaps object.
sl@0
   332
sl@0
   333
		@return KErrNone if successful.
sl@0
   334
	*/
sl@0
   335
	inline TInt DeviceCaps(TUsbDeviceCaps& aDevCapsBuf);
sl@0
   336
sl@0
   337
	/** Copies the current alternate setting for this interface into aInterfaceNumber
sl@0
   338
		For USB Interfaces whose main interface is active, this will be 0 (zero).
sl@0
   339
sl@0
   340
		@param aInterfaceNumber current alternate setting for this interface is copied into this.
sl@0
   341
sl@0
   342
		@return KErrNone if successful.
sl@0
   343
	*/
sl@0
   344
	inline TInt GetAlternateSetting(TInt& aInterfaceNumber);
sl@0
   345
sl@0
   346
	/** Copies the current device status into aDeviceStatus.
sl@0
   347
sl@0
   348
		@param aDeviceStatus current device status is copied into this.
sl@0
   349
sl@0
   350
		@return KErrNone if successful
sl@0
   351
	*/
sl@0
   352
	inline TInt DeviceStatus(TUsbcDeviceState& aDeviceStatus);
sl@0
   353
sl@0
   354
	/** Copies the current endpoint status into aEndpointStatus.
sl@0
   355
sl@0
   356
		@param aEndpoint endpoint number valid for the current alternate setting.
sl@0
   357
		@param aEndpointStatus the current endpoint status, might be stalled, not stalled or unknown.
sl@0
   358
sl@0
   359
		@return KErrNone if successful.
sl@0
   360
	*/
sl@0
   361
	inline TInt EndpointStatus(TEndpointNumber aEndpoint, TEndpointState& aEndpointStatus);
sl@0
   362
sl@0
   363
	/** Copies the number of bytes available in the aEndpoint read buffer into aNumberOfBytes.
sl@0
   364
sl@0
   365
		@param aEndpoint endpoint number valid for the current alternate setting.
sl@0
   366
		@param aNumberOfBytes number of bytes available in the aEndpoint read buffer.
sl@0
   367
sl@0
   368
		@return KErrNone if successful.
sl@0
   369
	*/
sl@0
   370
	inline TInt QueryReceiveBuffer(TEndpointNumber aEndpoint, TInt& aNumberOfBytes);
sl@0
   371
sl@0
   372
	/** Requests that a zero length status packet be sent to the host in response
sl@0
   373
		to a class or vendor specific ep0 SETUP packet.
sl@0
   374
sl@0
   375
		@return KErrNone if successful.
sl@0
   376
	*/
sl@0
   377
	inline TInt SendEp0StatusPacket();
sl@0
   378
sl@0
   379
	/** Stalls endpoint aEndpoint, usually to indicate an error condition with a previous command.
sl@0
   380
		The host will normally send a SET_FEATURE command on ep0 to acknowledge and clear the stall.
sl@0
   381
sl@0
   382
		@return KErrNone if successful.
sl@0
   383
	*/
sl@0
   384
	inline TInt HaltEndpoint(TEndpointNumber aEndpoint);
sl@0
   385
sl@0
   386
	/** Clears the stall condition on endpoint aEndpoint. This is inluded for symmetry and test purposes.
sl@0
   387
sl@0
   388
		@return KErrNone if successful.
sl@0
   389
	*/
sl@0
   390
	inline TInt ClearHaltEndpoint(TEndpointNumber aEndpoint);
sl@0
   391
sl@0
   392
	/** Requests that device control be allocated to this channel.
sl@0
   393
sl@0
   394
		@return KErrNone if successful.
sl@0
   395
	*/
sl@0
   396
	inline TInt SetDeviceControl();
sl@0
   397
sl@0
   398
	/** Relinquishes device control previously allocated to this channel.
sl@0
   399
sl@0
   400
		@return KErrNone if successful.
sl@0
   401
	*/
sl@0
   402
	inline TInt ReleaseDeviceControl();
sl@0
   403
sl@0
   404
	/** Returns a bitmap of available ep0 maximum packet sizes.
sl@0
   405
sl@0
   406
		@return bitmap of available ep0 maximum packet sizes.
sl@0
   407
	*/
sl@0
   408
	inline TUint EndpointZeroMaxPacketSizes();
sl@0
   409
sl@0
   410
	/** Requests that a maximum packet size of aMaxPacketSize be set on ep0.
sl@0
   411
sl@0
   412
		@param aMaxPacketSize The maximum packet size.
sl@0
   413
sl@0
   414
		@return KErrNone if successful.
sl@0
   415
	*/
sl@0
   416
	inline TInt SetEndpointZeroMaxPacketSize(TInt aMaxPacketSize);
sl@0
   417
sl@0
   418
	/** Queries the current maximum packet size on ep0.
sl@0
   419
sl@0
   420
		@return The currently set maximum packet size on ep0.
sl@0
   421
	*/
sl@0
   422
	inline TInt GetEndpointZeroMaxPacketSize();
sl@0
   423
sl@0
   424
	/** Copies the current device descriptor into aDeviceDescriptor.
sl@0
   425
sl@0
   426
		@param aDeviceDescriptor Receives the current device descriptor.
sl@0
   427
sl@0
   428
		@return KErrNone if successful.
sl@0
   429
	*/
sl@0
   430
	inline TInt GetDeviceDescriptor(TDes8& aDeviceDescriptor);
sl@0
   431
sl@0
   432
	/** Sets the contents of aDeviceDescriptor to be the current device descriptor.
sl@0
   433
sl@0
   434
		@param aDeviceDescriptor contains the device descriptor.
sl@0
   435
sl@0
   436
		@return KErrNone if successful.
sl@0
   437
	*/
sl@0
   438
	inline TInt SetDeviceDescriptor(const TDesC8& aDeviceDescriptor);
sl@0
   439
sl@0
   440
	/** Gets the size of the current device descriptor. This is unlikely to be anything other than 9.
sl@0
   441
sl@0
   442
		@param aSize receives the size of the current device descriptor.
sl@0
   443
sl@0
   444
		@return KErrNone if successful.
sl@0
   445
	*/
sl@0
   446
	inline TInt GetDeviceDescriptorSize(TInt& aSize);
sl@0
   447
sl@0
   448
	/** Copies the current configuration descriptor into aConfigurationDescriptor.
sl@0
   449
sl@0
   450
		@param aConfigurationDescriptor Receives the current configuration descriptor.
sl@0
   451
sl@0
   452
		@return KErrNone if successful.
sl@0
   453
	*/
sl@0
   454
	inline TInt GetConfigurationDescriptor(TDes8& aConfigurationDescriptor);
sl@0
   455
sl@0
   456
	/** Sets the contents of aConfigurationDescriptor to be the current configuration descriptor.
sl@0
   457
sl@0
   458
		@param aConfigurationDescriptor contains the configuration descriptor.
sl@0
   459
sl@0
   460
		@return KErrNone if successful.
sl@0
   461
	*/
sl@0
   462
	inline TInt SetConfigurationDescriptor(const TDesC8& aConfigurationDescriptor);
sl@0
   463
sl@0
   464
	/** Gets the size of the current configuration descriptor.
sl@0
   465
sl@0
   466
		@param aSize receives the size of the current configuration descriptor.
sl@0
   467
sl@0
   468
		@return KErrNone if successful.
sl@0
   469
	*/
sl@0
   470
	inline TInt GetConfigurationDescriptorSize(TInt& aSize);
sl@0
   471
sl@0
   472
	/** Copies the interface descriptor into aInterfaceDescriptor for the interface with alternate
sl@0
   473
		setting aSettingNumber, 0 for the main interface.
sl@0
   474
sl@0
   475
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   476
		@param aInterfaceDescriptor Receives the interface descriptor.
sl@0
   477
sl@0
   478
		@return KErrNone if successful.
sl@0
   479
	*/
sl@0
   480
	inline TInt GetInterfaceDescriptor(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
sl@0
   481
sl@0
   482
	/** Sets the interface descriptor contained in aInterfaceDescriptor for the interface with
sl@0
   483
		alternate setting aSettingNumber, 0 for the main interface, for transmission to the host
sl@0
   484
		during enumeration.
sl@0
   485
sl@0
   486
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   487
		@param aInterfaceDescriptor Contains the interface descriptor to be set.
sl@0
   488
sl@0
   489
		@return KErrNone if successful.
sl@0
   490
	*/
sl@0
   491
	inline TInt SetInterfaceDescriptor(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
sl@0
   492
sl@0
   493
	/** Copies the size of the interface descriptor for the interface with alternate
sl@0
   494
		setting aSettingNumber, 0 for the main interface, into aSize.
sl@0
   495
sl@0
   496
		@param aSettingNumber The alternate setting.
sl@0
   497
		@param aSize receives the size of the interface descriptor.
sl@0
   498
sl@0
   499
		@return KErrNone if successful.
sl@0
   500
	*/
sl@0
   501
	inline TInt GetInterfaceDescriptorSize(TInt aSettingNumber, TInt& aSize);
sl@0
   502
sl@0
   503
	/** Copies the endpoint descriptor for logical endpoint number aEndpointNumber into aEndpointDescriptor
sl@0
   504
		for the interface with alternate setting aSettingNumber, 0 for the main interface.
sl@0
   505
sl@0
   506
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   507
		@param aEndpointNumber.
sl@0
   508
		@param aEndpointDescriptor Receives the endpoint descriptor.
sl@0
   509
sl@0
   510
		@return KErrNone if successful.
sl@0
   511
	*/
sl@0
   512
	inline TInt GetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber, TDes8& aEndpointDescriptor);
sl@0
   513
sl@0
   514
	/** Sets the endpoint descriptor for logical endpoint number aEndpointNumber contained in
sl@0
   515
		aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
sl@0
   516
		for transmission to the host during enumeration.
sl@0
   517
sl@0
   518
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   519
		@param aEndpointNumber Valid endpoint number on this interface.
sl@0
   520
		@param aEndpointDescriptor Contains the endpoint descriptor to be set.
sl@0
   521
sl@0
   522
		@return KErrNone if successful.
sl@0
   523
	*/
sl@0
   524
	inline TInt SetEndpointDescriptor(TInt aSettingNumber, TInt aEndpointNumber,
sl@0
   525
									  const TDesC8& aEndpointDescriptor);
sl@0
   526
sl@0
   527
	/** Copies the size of the endpoint descriptor for logical endpoint number aEndpointNumber for the
sl@0
   528
		interface with alternate setting aSettingNumber, 0 for the main interface, into aSize.
sl@0
   529
sl@0
   530
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   531
		@param aEndpointNumber Valid endpoint number on this interface.
sl@0
   532
		@param aSize receives the size of the endpoint descriptor.
sl@0
   533
sl@0
   534
		@return KErrNone if successful.
sl@0
   535
	*/
sl@0
   536
	inline TInt GetEndpointDescriptorSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
sl@0
   537
sl@0
   538
    /** Get OTG descriptor size
sl@0
   539
sl@0
   540
		@param aSize TInt reference which contains OTG descriptor size on return
sl@0
   541
    */
sl@0
   542
    inline void GetOtgDescriptorSize(TInt& aSize);
sl@0
   543
sl@0
   544
    /** Get OTG descriptor of USB on-the-go feature
sl@0
   545
sl@0
   546
		@param aOtgDesc User-side buffer to store copy of descriptor
sl@0
   547
sl@0
   548
		@return KErrNone if successful
sl@0
   549
    */
sl@0
   550
    inline TInt GetOtgDescriptor(TDes8& aOtgDesc);
sl@0
   551
sl@0
   552
    /** Set OTG descriptor by user to enable/disable USB on-the-go feature
sl@0
   553
sl@0
   554
		@param aOtgDesc Descriptor buffer containing OTG features
sl@0
   555
sl@0
   556
		@return KErrNone if successful
sl@0
   557
    */
sl@0
   558
    inline TInt SetOtgDescriptor(const TDesC8& aOtgDesc);
sl@0
   559
sl@0
   560
	/** Copies the current device_qualifier descriptor into aDescriptor.
sl@0
   561
sl@0
   562
		@param aDescriptor Receives the current device_qualifier descriptor.
sl@0
   563
sl@0
   564
		@return KErrNone if successful.
sl@0
   565
	*/
sl@0
   566
	inline TInt GetDeviceQualifierDescriptor(TDes8& aDescriptor);
sl@0
   567
sl@0
   568
	/** Sets the device_qualifier descriptor to the contents of aDescriptor.
sl@0
   569
sl@0
   570
		@param aDescriptor contains the new device_qualifier descriptor.
sl@0
   571
sl@0
   572
		@return KErrNone if successful.
sl@0
   573
	*/
sl@0
   574
	inline TInt SetDeviceQualifierDescriptor(const TDesC8& aDescriptor);
sl@0
   575
sl@0
   576
	/** Copies the current other_speed_configuration descriptor into aDescriptor.
sl@0
   577
sl@0
   578
		@param aDescriptor Receives the current other_speed_configuration descriptor.
sl@0
   579
sl@0
   580
		@return KErrNone if successful.
sl@0
   581
	*/
sl@0
   582
	inline TInt GetOtherSpeedConfigurationDescriptor(TDes8& aDescriptor);
sl@0
   583
sl@0
   584
	/** Sets the other_speed_configuration descriptor to the contents of aDescriptor.
sl@0
   585
sl@0
   586
		@param aDescriptor contains the new other_speed_configuration descriptor.
sl@0
   587
sl@0
   588
		@return KErrNone if successful.
sl@0
   589
	*/
sl@0
   590
	inline TInt SetOtherSpeedConfigurationDescriptor(const TDesC8& aDescriptor);
sl@0
   591
sl@0
   592
	/** Copies the class specific interface descriptor block into aInterfaceDescriptor for the interface
sl@0
   593
		with alternate setting aSettingNumber, 0 for the main interface.
sl@0
   594
sl@0
   595
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   596
		@param aInterfaceDescriptor Contains the interface descriptor to be set.
sl@0
   597
sl@0
   598
		@return KErrNone if successful.
sl@0
   599
	*/
sl@0
   600
	inline TInt GetCSInterfaceDescriptorBlock(TInt aSettingNumber, TDes8& aInterfaceDescriptor);
sl@0
   601
sl@0
   602
	/** aSettingNumber is the alternate interface setting, 0 for the main interface, that the descriptor block
sl@0
   603
		aDes should be attached to. aDes is a block of data containing at least one class specific descriptor
sl@0
   604
		for transmission during enumeration after the class interface descriptor (or alternate interface
sl@0
   605
		descriptor) has been sent, but before the endpoint descriptors belonging to this interface are sent.
sl@0
   606
		aDes may contain as many descriptors as are necessary or only 1. SetCSInterfaceDescriptorBlock()
sl@0
   607
		should be called at any time after SetInterface() has been called to establish a main interface or an
sl@0
   608
		alternate interface. More than one call may be made - the data blocks will be concatenated prior to
sl@0
   609
		sending. No checking or validation of the contents of aDes will be made and it is the caller's
sl@0
   610
		responsibility to ensure that the data supplied is correct and appropriate to the interface identified
sl@0
   611
		by aSettingNumber.
sl@0
   612
sl@0
   613
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   614
		@param aInterfaceDescriptor Contains the interface descriptor to be set.
sl@0
   615
sl@0
   616
		@return KErrNone if successful.
sl@0
   617
	*/
sl@0
   618
	inline TInt SetCSInterfaceDescriptorBlock(TInt aSettingNumber, const TDesC8& aInterfaceDescriptor);
sl@0
   619
sl@0
   620
	/** Copies the size of the class specific interface descriptor block for the interface with alternate
sl@0
   621
		setting aSettingNumber, 0 for the main interface, into aSize.
sl@0
   622
sl@0
   623
		@param aSettingNumber The alternate setting number.
sl@0
   624
		@param aSize receives the size of the interface descriptor.
sl@0
   625
sl@0
   626
		@return KErrNone if successful.
sl@0
   627
	*/
sl@0
   628
	inline TInt GetCSInterfaceDescriptorBlockSize(TInt aSettingNumber, TInt& aSize);
sl@0
   629
sl@0
   630
	/** Copies the class specific endpoint descriptor for logical endpoint number aEndpointNumber
sl@0
   631
		into aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main
sl@0
   632
		interface.
sl@0
   633
sl@0
   634
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   635
		@param aEndpointNumber Valid endpoint number on this interface.
sl@0
   636
		@param aEndpointDescriptor Receives the endpoint descriptor.
sl@0
   637
sl@0
   638
		@return KErrNone if successful.
sl@0
   639
	*/
sl@0
   640
	inline TInt GetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
sl@0
   641
											 TDes8& aEndpointDescriptor);
sl@0
   642
sl@0
   643
	/** Sets the class specific endpoint descriptor for logical endpoint number aEndpointNumber contained in
sl@0
   644
		aEndpointDescriptor for the interface with alternate setting aSettingNumber, 0 for the main interface,
sl@0
   645
		for transmission to the host during enumeration.
sl@0
   646
sl@0
   647
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   648
		@param aEndpointNumber Valid endpoint number on this interface.
sl@0
   649
		@param aEndpointDescriptor Contains the endpoint descriptor to be set.
sl@0
   650
sl@0
   651
		@return KErrNone if successful.
sl@0
   652
	*/
sl@0
   653
	inline TInt SetCSEndpointDescriptorBlock(TInt aSettingNumber, TInt aEndpointNumber,
sl@0
   654
											 const TDesC8& aEndpointDescriptor);
sl@0
   655
sl@0
   656
	/** Copies the size of the class specific endpoint descriptor block for logical endpoint number
sl@0
   657
		aEndpointNumber for the interface with alternate setting aSettingNumber, 0 for the main interface,
sl@0
   658
		into aSize.
sl@0
   659
sl@0
   660
		@param aSettingNumber Alternate setting number on the interface, 0 for the main interface.
sl@0
   661
		@param aEndpointNumber Valid endpoint number on this interface.
sl@0
   662
		@param aSize On return, contains the size of the class specific endpoint descriptor block.
sl@0
   663
sl@0
   664
		@return KErrNone if successful.
sl@0
   665
	*/
sl@0
   666
	inline TInt GetCSEndpointDescriptorBlockSize(TInt aSettingNumber, TInt aEndpointNumber, TInt& aSize);
sl@0
   667
sl@0
   668
	/** Generates a Remote Wakeup bus condition
sl@0
   669
		The capability of the device to generate Remote Wakeup signalling is enquired in
sl@0
   670
		RDevUsbcClient::DeviceCaps.
sl@0
   671
sl@0
   672
		@return KErrNone if this signalling is possible and the signal has been generated.
sl@0
   673
	*/
sl@0
   674
	inline TInt SignalRemoteWakeup();
sl@0
   675
sl@0
   676
	/** Simulates a physical removal of the USB cable by disabling the D+/- pull-ups.The iConnect member of
sl@0
   677
		TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(), indicates whether this functionality is
sl@0
   678
		supported.
sl@0
   679
sl@0
   680
		@return KErrNone if successful.
sl@0
   681
	*/
sl@0
   682
	inline TInt DeviceDisconnectFromHost();
sl@0
   683
sl@0
   684
	/** Simulates a physical insertion of the USB cable by enabling the D+/- pull-ups.The iConnect member
sl@0
   685
		of TUsbDeviceCapsV01, returned by RDevUsbcClient::DeviceCaps(),  indicates whether this functionality
sl@0
   686
		is supported.
sl@0
   687
sl@0
   688
		@return KErrNone if successful.
sl@0
   689
	*/
sl@0
   690
	inline TInt DeviceConnectToHost();
sl@0
   691
sl@0
   692
	/** Powers up the UDC and connects it to the bus if one or more interfaces exist.
sl@0
   693
sl@0
   694
		@return KErrNone if UDC successfully powered up, KErrNotReady if no
sl@0
   695
		interfaces have been registered yet, KErrHardwareNotAvailable if UDC
sl@0
   696
		couldn't be activated.
sl@0
   697
	*/
sl@0
   698
	inline TInt PowerUpUdc();
sl@0
   699
sl@0
   700
	/** Enquires about the current operating speed of the UDC.
sl@0
   701
sl@0
   702
		@return ETrue if the UDC is currently operating at High speed, EFalse otherwise.
sl@0
   703
	*/
sl@0
   704
	inline TBool CurrentlyUsingHighSpeed();
sl@0
   705
sl@0
   706
	/** Allocates the use of aResource to aEndpoint. it will be used from when the current bus transfer	has been
sl@0
   707
		completed.
sl@0
   708
sl@0
   709
		@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
sl@0
   710
		behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
sl@0
   711
		@param aEndpoint The endpoint number to which the resource is to be allocated.
sl@0
   712
sl@0
   713
		@return KErrNone if successful, KErrInUse if the resource is already consumed and cannot be allocated,
sl@0
   714
		KErrNotSupported if the endpoint does not support the resource requested.
sl@0
   715
sl@0
   716
		@publishedPartner @deprecated
sl@0
   717
sl@0
   718
		@see TUsbcEndpointInfo
sl@0
   719
	*/
sl@0
   720
	inline TInt AllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
sl@0
   721
sl@0
   722
	/** Deallocates the use of aResource aEndpoint or ends a specified endpoint behaviour.
sl@0
   723
sl@0
   724
		@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
sl@0
   725
		behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
sl@0
   726
		@param aEndpoint The endpoint number from which the resource is to be removed.
sl@0
   727
sl@0
   728
		@return KErrNone if the resource has been successfully deallocated, KErrNotSupported if the endpoint
sl@0
   729
		does not support the resource requested.
sl@0
   730
sl@0
   731
		@publishedPartner @deprecated
sl@0
   732
sl@0
   733
		@see TUsbcEndpointInfo
sl@0
   734
	*/
sl@0
   735
	inline TInt DeAllocateEndpointResource(TInt aEndpoint, TUsbcEndpointResource aResource);
sl@0
   736
sl@0
   737
	/** Queries endpoint resource use.
sl@0
   738
sl@0
   739
		@param aResource is typically some rationed hardware resource or possibly specifies a type of endpoint
sl@0
   740
		behaviour. aResource is not a bitmap and TEndpointResource values should not be combined.
sl@0
   741
		@param aEndpoint The endpoint number at which the resource is to be queried.
sl@0
   742
sl@0
   743
		@return ETrue is the specified resource is in use at the endpoint and EFalse if not.
sl@0
   744
	*/
sl@0
   745
	inline TBool QueryEndpointResourceUse(TInt aEndpoint, TUsbcEndpointResource aResource);
sl@0
   746
sl@0
   747
	/** Request (i.e. claim for this channel) up to five endpoints and set the class type for this USB
sl@0
   748
		interface. 'aInterfaceData' is a package buffer which describes the interface and all the endpoints
sl@0
   749
		being requested by the driver for this interface.
sl@0
   750
sl@0
   751
		@param aInterfaceNumber Distinguishes between alternate interfaces. If these are not be used then this
sl@0
   752
		should always be zero. If this parameter is used, then its value must be one more than that of the
sl@0
   753
		proceeding alternate interface.
sl@0
   754
		@param aInterfaceData a package buffer which describes the interface and all the endpoints being
sl@0
   755
		requested by the driver for this interface.
sl@0
   756
		@param aBandwidthPriority is a bitmap combining the required IN and OUT priorities. Values are in the
sl@0
   757
		range [0,3] from the lowest priority bandwidth, 0, to the highest 3 and are separately specified for
sl@0
   758
		IN and OUT endpoints. Interfaces requiring higher bandwidth are allocated significantly more buffering
sl@0
   759
		than low bandwidth interfaces. Interfaces should not be given a higher bandwidth priority than they
sl@0
   760
		require.
sl@0
   761
sl@0
   762
		@return KErrInUse if any of the endpoints being requested have already been claimed by another channel
sl@0
   763
		KErrNotSupported if an endpoint with all of the specified properties is not supported on this
sl@0
   764
		platform. KErrNoMemory if insufficient memory is available to complete the operation.
sl@0
   765
	*/
sl@0
   766
	inline TInt SetInterface(TInt aInterfaceNumber, TUsbcInterfaceInfoBuf& aInterfaceData,
sl@0
   767
							 TUint32 aBandwidthPriority =
sl@0
   768
							 (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault));
sl@0
   769
sl@0
   770
	/** Release an interface previously claimed by this channel. Alternate interfaces need to be released
sl@0
   771
		in strict descending order, starting with the last (i.e. highest numbered) one.
sl@0
   772
		It is not necessary to release an interface that wasn't successfully requested.
sl@0
   773
sl@0
   774
		@param aInterfaceNumber Specifies the alternate setting number 'aInterfaceNum' of the interface to be
sl@0
   775
		released.
sl@0
   776
sl@0
   777
		@return KErrNone if successful. KErrArgument if the alternate setting doesn't exist or is released out
sl@0
   778
		of order.
sl@0
   779
	*/
sl@0
   780
	inline TInt ReleaseInterface(TInt aInterfaceNumber);
sl@0
   781
sl@0
   782
	/** Copies the current string descriptor language ID (LANGID) code into the aLangId argument. Even though
sl@0
   783
		the USB spec allows for the existence of a whole array of LANGID codes, we only support one.
sl@0
   784
sl@0
   785
		@param aLangId receives the LANGID code.
sl@0
   786
sl@0
   787
		@return KErrNone if successful, KErrArgument if problem with argument (memory cannot be written to, etc.).
sl@0
   788
	*/
sl@0
   789
	inline TInt GetStringDescriptorLangId(TUint16& aLangId);
sl@0
   790
sl@0
   791
	/** Sets the string descriptor language ID (LANGID). Even though the USB spec allows for the existence of
sl@0
   792
		a whole array of LANGID codes, we only support one.
sl@0
   793
sl@0
   794
		@param aLangId the LANGID code to be set.
sl@0
   795
sl@0
   796
		@return KErrNone if successful.
sl@0
   797
	*/
sl@0
   798
	inline TInt SetStringDescriptorLangId(TUint16 aLangId);
sl@0
   799
sl@0
   800
	/** Copies the string descriptor identified by the iManufacturer index field of the Standard Device
sl@0
   801
		Descriptor into the aString argument.
sl@0
   802
sl@0
   803
		@param aString receives manufacturer string.
sl@0
   804
sl@0
   805
		@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
sl@0
   806
		descriptor, KErrNotFound if the string descriptor couldn't be found.
sl@0
   807
	*/
sl@0
   808
	inline TInt GetManufacturerStringDescriptor(TDes16& aString);
sl@0
   809
sl@0
   810
	/** Sets the string descriptor identified by the iManufacturer index field of the Standard Device
sl@0
   811
		Descriptor to the aString argument.
sl@0
   812
sl@0
   813
		@param aString Contains the new manufacturer string descriptor.
sl@0
   814
sl@0
   815
		@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
sl@0
   816
		aString (in which case the old string descriptor will be preserved).
sl@0
   817
	*/
sl@0
   818
	inline TInt SetManufacturerStringDescriptor(const TDesC16& aString);
sl@0
   819
sl@0
   820
	/** Removes (deletes) the string descriptor identified by the iManufacturer index field of the Standard
sl@0
   821
		Device Descriptor and sets that field to zero.
sl@0
   822
sl@0
   823
		@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
sl@0
   824
	*/
sl@0
   825
	inline TInt RemoveManufacturerStringDescriptor();
sl@0
   826
sl@0
   827
	/** Retrieves the string descriptor identified by the iProduct index field of the Standard Device
sl@0
   828
		Descriptor into the aString argument.
sl@0
   829
sl@0
   830
		@param aString receives product string.
sl@0
   831
sl@0
   832
		@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
sl@0
   833
		descriptor, KErrNotFound if the string descriptor couldn't be found.
sl@0
   834
	*/
sl@0
   835
	inline TInt GetProductStringDescriptor(TDes16& aString);
sl@0
   836
sl@0
   837
	/** Sets the string descriptor identified by the iProduct index field of the Standard Device Descriptor to
sl@0
   838
		the aString argument.
sl@0
   839
sl@0
   840
		@param aString Contains the new product string descriptor.
sl@0
   841
sl@0
   842
		@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
sl@0
   843
		aString (in which case the old string descriptor will be preserved).
sl@0
   844
	*/
sl@0
   845
	inline TInt SetProductStringDescriptor(const TDesC16& aString);
sl@0
   846
sl@0
   847
	/** Removes (deletes) the string descriptor identified by the iProduct index field of the Standard Device
sl@0
   848
		Descriptor and sets that field to zero.
sl@0
   849
sl@0
   850
		@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
sl@0
   851
	*/
sl@0
   852
	inline TInt RemoveProductStringDescriptor();
sl@0
   853
sl@0
   854
	/** Retrieves the string descriptor identified by the iSerialNumber index field of the Standard Device
sl@0
   855
		Descriptor into the aString argument.
sl@0
   856
sl@0
   857
		@param aString receives product string.
sl@0
   858
sl@0
   859
		@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
sl@0
   860
		descriptor, KErrNotFound if the string descriptor couldn't be found.
sl@0
   861
	*/
sl@0
   862
	inline TInt GetSerialNumberStringDescriptor(TDes16& aString);
sl@0
   863
sl@0
   864
	/** Sets the string descriptor identified by the iSerialNumber index field of the Standard Device
sl@0
   865
		Descriptor to the aString argument.
sl@0
   866
sl@0
   867
		@param aString Contains the new serial number string descriptor.
sl@0
   868
sl@0
   869
		@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
sl@0
   870
		aString (in which case the old string descriptor will be preserved).
sl@0
   871
	*/
sl@0
   872
	inline TInt SetSerialNumberStringDescriptor(const TDesC16& aString);
sl@0
   873
sl@0
   874
	/** Removes (deletes) the string descriptor identified by the iSerialNumber index field of the Standard
sl@0
   875
		Device Descriptor and sets that field to zero.
sl@0
   876
sl@0
   877
		@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
sl@0
   878
	*/
sl@0
   879
	inline TInt RemoveSerialNumberStringDescriptor();
sl@0
   880
sl@0
   881
	/** Retrieves the string descriptor identified by the iConfiguration index field of the (first) Standard
sl@0
   882
		Configuration Descriptor into the aString argument.
sl@0
   883
sl@0
   884
		@param aString receives configuration string.
sl@0
   885
sl@0
   886
		@return KErrNone if successful, KErrArgument if MaxLength of aString is too small to hold the entire
sl@0
   887
		descriptor, KErrNotFound if the string descriptor couldn't be found.
sl@0
   888
	*/
sl@0
   889
	inline TInt GetConfigurationStringDescriptor(TDes16& aString);
sl@0
   890
sl@0
   891
	/** Sets the string descriptor identified by the iConfiguration index field of the Standard Configuration
sl@0
   892
		Descriptor to the aString argument.
sl@0
   893
sl@0
   894
		@param aString Contains the new serial number string descriptor.
sl@0
   895
sl@0
   896
		@return KErrNone if successful, KErrNoMemory if no memory is available to store the new string from
sl@0
   897
		aString (in which case the old string descriptor will be preserved).
sl@0
   898
	*/
sl@0
   899
	inline TInt SetConfigurationStringDescriptor(const TDesC16& aString);
sl@0
   900
sl@0
   901
	/** Removes (deletes) the string descriptor identified by the iConfiguration index field of the Standard
sl@0
   902
		Configuration Descriptor and sets that field to zero.
sl@0
   903
sl@0
   904
		@return KErrNone if successful, KErrNotFound if the string descriptor couldn't be found.
sl@0
   905
	*/
sl@0
   906
	inline TInt RemoveConfigurationStringDescriptor();
sl@0
   907
sl@0
   908
	/** Copies the string of the USB string descriptor at the specified index in the string descriptor array
sl@0
   909
		into the aString argument.
sl@0
   910
sl@0
   911
		Although this function can also be used for it, for querying most standard string descriptors
sl@0
   912
		there exists a set of dedicated access functions.
sl@0
   913
sl@0
   914
		@see RDevUsbcClient::GetStringDescriptorLangId
sl@0
   915
		@see RDevUsbcClient::GetManufacturerStringDescriptor
sl@0
   916
		@see RDevUsbcClient::GetProductStringDescriptor
sl@0
   917
		@see RDevUsbcClient::GetSerialNumberStringDescriptor
sl@0
   918
		@see RDevUsbcClient::GetConfigurationStringDescriptor
sl@0
   919
sl@0
   920
		@param aIndex The position of the string descriptor in the string descriptor array.
sl@0
   921
		@param aString The target location for the string descriptor copy.
sl@0
   922
sl@0
   923
		@return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index,
sl@0
   924
		KErrArgument if MaxLength() of aString is too small to hold the entire descriptor.
sl@0
   925
	*/
sl@0
   926
	inline TInt GetStringDescriptor(TUint8 aIndex, TDes16& aString);
sl@0
   927
sl@0
   928
	/** Sets the aString argument to be the string of a USB string descriptor at the specified index in the
sl@0
   929
		string descriptor array. If a string descriptor already exists at that position then its string will
sl@0
   930
		be replaced.
sl@0
   931
sl@0
   932
		Care should be taken, when choosing aIndex, not to inadvertently overwrite one of the standard
sl@0
   933
		string descriptors.	For their manipulation there exists a set of dedicated access functions.
sl@0
   934
sl@0
   935
		@see RDevUsbcClient::SetStringDescriptorLangId
sl@0
   936
		@see RDevUsbcClient::SetManufacturerStringDescriptor
sl@0
   937
		@see RDevUsbcClient::SetProductStringDescriptor
sl@0
   938
		@see RDevUsbcClient::SetSerialNumberStringDescriptor
sl@0
   939
		@see RDevUsbcClient::SetConfigurationStringDescriptor
sl@0
   940
sl@0
   941
		@param aIndex The position of the string descriptor in the string descriptor array.
sl@0
   942
		@param aString Contains the string descriptor to be set.
sl@0
   943
sl@0
   944
		@return KErrNone if successful, KErrArgument if aIndex is invalid, KErrNoMemory if no memory
sl@0
   945
		is available to store the new string (an existing descriptor at that index will be preserved).
sl@0
   946
	*/
sl@0
   947
	inline TInt SetStringDescriptor(TUint8 aIndex, const TDesC16& aString);
sl@0
   948
sl@0
   949
	/** Removes (deletes) the USB string descriptor at the specified index in the string descriptor array.
sl@0
   950
		The position in the array of other string descriptors is not affected.
sl@0
   951
sl@0
   952
		Care should be taken, when choosing aIndex, not to inadvertently delete a standard string descriptor
sl@0
   953
		(also because index references from non-string descriptors would be invalidated). For the deletion
sl@0
   954
		of most standard string descriptors there exists a set of dedicated functions.
sl@0
   955
sl@0
   956
		@see RDevUsbcClient::RemoveManufacturerStringDescriptor
sl@0
   957
		@see RDevUsbcClient::RemoveProductStringDescriptor
sl@0
   958
		@see RDevUsbcClient::RemoveSerialNumberStringDescriptor
sl@0
   959
		@see RDevUsbcClient::RemoveConfigurationStringDescriptor
sl@0
   960
sl@0
   961
		@param aIndex The position of the string descriptor in the string descriptor array.
sl@0
   962
sl@0
   963
		@return KErrNone if successful, KErrNotFound if no string descriptor exists at the specified index.
sl@0
   964
	*/
sl@0
   965
	inline TInt RemoveStringDescriptor(TUint8 aIndex);
sl@0
   966
sl@0
   967
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'.
sl@0
   968
		Request completes when the specified number of bytes is received, length taken from max. length of
sl@0
   969
		descriptor.
sl@0
   970
sl@0
   971
		@param aStatus The request status.
sl@0
   972
		@param aEndpoint The endpoint number to read from.
sl@0
   973
		@param aDes	Descriptor to receive the data.
sl@0
   974
	*/
sl@0
   975
	inline void Read(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes);
sl@0
   976
sl@0
   977
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'.
sl@0
   978
		Request completes when the specified number of bytes is received.
sl@0
   979
sl@0
   980
		@param aStatus The request status.
sl@0
   981
		@param aEndpoint The endpoint number to read from.
sl@0
   982
		@param aDes	Descriptor to receive the data.
sl@0
   983
		@param aLen The number of bytes to read.
sl@0
   984
	*/
sl@0
   985
	inline void Read(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes, TInt aLen);
sl@0
   986
sl@0
   987
	/** Asynchronously read an entire packet of data from endpoint 'aEndpoint' into the descriptor 'aDes'.
sl@0
   988
		If a packet has previously been partly read. then only the remainder of the packet will be returned.
sl@0
   989
		The request should be for the maximum packet size of the endpoint. If less data is requested, then
sl@0
   990
		after this read completes the remainder of the data in the packet will be discarded and the next read
sl@0
   991
		will start from the next available packet.
sl@0
   992
		Request completes when either a complete packet is received or the length of the packet currently
sl@0
   993
		being received exceeds 'aMaxLen'.
sl@0
   994
sl@0
   995
		@param aStatus The request status.
sl@0
   996
		@param aEndpoint The endpoint number to read from.
sl@0
   997
		@param aDes	Descriptor to receive the data.
sl@0
   998
		@param aMaxLen .
sl@0
   999
	*/
sl@0
  1000
	inline void ReadPacket(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes, TInt aMaxLen);
sl@0
  1001
sl@0
  1002
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'.
sl@0
  1003
		Request completes when the specified number of bytes is received (in first version,
sl@0
  1004
		length taken from max. length of descriptor).
sl@0
  1005
sl@0
  1006
		@param aStatus The request status.
sl@0
  1007
		@param aEndpoint The endpoint number to read from.
sl@0
  1008
		@param aDes	Descriptor to receive the data.
sl@0
  1009
	*/
sl@0
  1010
	inline void ReadUntilShort(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes);
sl@0
  1011
sl@0
  1012
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'.
sl@0
  1013
		Request completes when the specified number of bytes is received (in first version,
sl@0
  1014
		length taken from max. length of descriptor).
sl@0
  1015
sl@0
  1016
		@param aStatus The request status.
sl@0
  1017
		@param aEndpoint The endpoint number to read from.
sl@0
  1018
		@param aDes	Descriptor to receive the data.
sl@0
  1019
		@param aLen The number of bytes to receive.
sl@0
  1020
	*/
sl@0
  1021
	inline void ReadUntilShort(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes, TInt aLen);
sl@0
  1022
sl@0
  1023
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'. The request completes
sl@0
  1024
		when the specified number of bytes is received, length taken from max. length of descriptor or a
sl@0
  1025
		packet whose size is smaller than the endpoint's maximum packet size is received.
sl@0
  1026
sl@0
  1027
		@param aStatus The request status.
sl@0
  1028
		@param aEndpoint The endpoint number to read from.
sl@0
  1029
		@param aDes	Descriptor to receive the data.
sl@0
  1030
	*/
sl@0
  1031
	inline void ReadOneOrMore(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes);
sl@0
  1032
sl@0
  1033
	/** Asynchronously read data from endpoint 'aEndpoint' into the descriptor 'aDes'. The request completes
sl@0
  1034
		when the specified number of bytes is received, or a packet whose size is smaller than the endpoint's
sl@0
  1035
		maximum packet size is received.
sl@0
  1036
sl@0
  1037
		@param aStatus The request status.
sl@0
  1038
		@param aEndpoint The endpoint number to read from.
sl@0
  1039
		@param aDes	Descriptor to receive the data.
sl@0
  1040
		@param aLen The number of bytes to receive.
sl@0
  1041
	*/
sl@0
  1042
	inline void ReadOneOrMore(TRequestStatus& aStatus, TEndpointNumber aEndpoint, TDes8& aDes, TInt aLen);
sl@0
  1043
sl@0
  1044
	/** Cancels an outstanding read request. The request will complete with whatever data is available.
sl@0
  1045
	*/
sl@0
  1046
	inline void ReadCancel(TEndpointNumber aEndpoint);
sl@0
  1047
sl@0
  1048
	/** Asynchronously write 'aLen' bytes of data to endpoint 'aEndpoint' from descriptor 'aDes'. 'aZlpRequired'
sl@0
  1049
		(optional) signals that ZLP termination may be required.
sl@0
  1050
sl@0
  1051
		@param aStatus The request status.
sl@0
  1052
		@param aEndpoint The endpoint number to write to.
sl@0
  1053
		@param aDes	Descriptor to provide the data.
sl@0
  1054
		@param aLen The number of bytes of data to be written.
sl@0
  1055
		@param aZlpRequired True, if ZLP termination is required; false, otherwise.
sl@0
  1056
	*/
sl@0
  1057
	inline void Write(TRequestStatus& aStatus, TEndpointNumber aEndpoint, const TDesC8& aDes, TInt aLen,
sl@0
  1058
					  TBool aZlpRequired=EFalse);
sl@0
  1059
sl@0
  1060
	/** Cancels an outstanding write request on endpoint aEndpoint.
sl@0
  1061
sl@0
  1062
		@param aEndpoint The endpoint number whose write is to be cancelled.
sl@0
  1063
	*/
sl@0
  1064
	inline void WriteCancel(TEndpointNumber aEndpoint);
sl@0
  1065
sl@0
  1066
	/** Cancels any transfer on any endpoint specified in aEndpointMask.
sl@0
  1067
sl@0
  1068
		@code
sl@0
  1069
		// Cancel transfer requests on endpoints 1, 2 & 3
sl@0
  1070
		usbPort.EndpointTransferCancel(KUsbcEndpoint1Bit | KUsbcEndpoint2Bit | KUsbcEndpoint3Bit);
sl@0
  1071
		@endcode
sl@0
  1072
sl@0
  1073
		@param aEndpointMask bitmap of the endpoints.
sl@0
  1074
	*/
sl@0
  1075
	inline void EndpointTransferCancel(TUint aEndpointMask);
sl@0
  1076
sl@0
  1077
	/**	Register for notification when a change of the Interface alternate setting or the USB Controller's
sl@0
  1078
		current state occurs. When the alternate setting or the Controller state changes, then the
sl@0
  1079
		asynchronous function completes and the current alternate setting number or Controller state is
sl@0
  1080
		written back to aValue. If the KUsbAlternateSetting bit is set then the remaining bits are the
sl@0
  1081
		alternate setting number. Otherwise aValue is interpreted as a TUsbcDeviceState.
sl@0
  1082
sl@0
  1083
		@see TUsbcDeviceState
sl@0
  1084
sl@0
  1085
		@param aStatus The request status.
sl@0
  1086
		@param aValue Receives the alternate setting number or Controller state.
sl@0
  1087
	*/
sl@0
  1088
	inline void AlternateDeviceStatusNotify(TRequestStatus& aStatus, TUint& aValue);
sl@0
  1089
sl@0
  1090
	/** Completes an AlternateDeviceStatusNotify request. If a request has previously been made then the
sl@0
  1091
		status variable is updated with the current device state.
sl@0
  1092
	*/
sl@0
  1093
	inline void AlternateDeviceStatusNotifyCancel();
sl@0
  1094
sl@0
  1095
	/** If the channel has changed the grouping of endpoints between interfaces or changed the interface class
sl@0
  1096
		type from the defaults then it is necessary to force a re-enumeration. This will typically involve the
sl@0
  1097
		Symbian OS device initiating a disconnection and re-connection. This is an asynchronous operation
sl@0
  1098
		which will complete when the Controller is successfully configured by the host, i.e. has achieved
sl@0
  1099
		EUsbcDeviceStateConfigured.  Since it is not known if the operation has failed, at the same time that
sl@0
  1100
		a ReEnumerate request is made, a timer should be set up to complete after approximately 5 seconds. It
sl@0
  1101
		can be assumed that if the operation has not completed after this time interval then it will not
sl@0
  1102
		complete.
sl@0
  1103
sl@0
  1104
		@param aStatus The request status.
sl@0
  1105
	*/
sl@0
  1106
	inline void ReEnumerate(TRequestStatus& aStatus);
sl@0
  1107
sl@0
  1108
	/** Cancels an outstanding ReEnumerate() request.
sl@0
  1109
	*/
sl@0
  1110
	inline void ReEnumerateCancel();
sl@0
  1111
sl@0
  1112
	/**	Register for notification when a change in stall status of any of the interface's endpoints occurs,
sl@0
  1113
		but not ep0. When a change in stall status occurs, then the asynchronous function completes and the
sl@0
  1114
		current stall state is written back to 'aEndpointStatus' as a bit map: Only stall state changes caused
sl@0
  1115
		by SET_FEATURE and CLEAR_FEATURE standard commands on ep0 will be notified when this function
sl@0
  1116
		completes. After this request completes the request should be re-issued to obtain future
sl@0
  1117
		notifications.
sl@0
  1118
sl@0
  1119
		@param aStatus The request status.
sl@0
  1120
		@param aEndpointMask a bitmap of the endpoints stall status. This is filled in when the call completes
sl@0
  1121
		bit 1 represents the interface's virtual endpoint 1, (KUsbcEndpoint1Bit)
sl@0
  1122
		bit 2 represents the interface's virtual endpoint 2, (KUsbcEndpoint2Bit) etc.
sl@0
  1123
		bit value 0 - not stalled,
sl@0
  1124
		bit value 1 - stalled.
sl@0
  1125
	*/
sl@0
  1126
	inline void EndpointStatusNotify(TRequestStatus& aStatus, TUint& aEndpointMask);
sl@0
  1127
sl@0
  1128
	/** Completes an endpoint status notify request.
sl@0
  1129
	*/
sl@0
  1130
 	inline void EndpointStatusNotifyCancel();
sl@0
  1131
sl@0
  1132
    /** Get current on-the-go features relating to the ability of device/host pair to
sl@0
  1133
        perform OTG role swap.
sl@0
  1134
sl@0
  1135
        @param aFeatures On return it contanis features the device currently has
sl@0
  1136
                bit 2 represents b_hnp_enable,       (KUsbOtgAttr_B_HnpEnable)
sl@0
  1137
                bit 3 represents a_hnp_support,      (KUsbOtgAttr_A_HnpSupport)
sl@0
  1138
                bit 4 represents a_alt_hnp_support,  (KUsbOtgAttr_A_AltHnpSupport)
sl@0
  1139
        @return KErrNone if successful, KErrNotSupported if OTG is not supported by
sl@0
  1140
                this device, otherwise system-wide error returns
sl@0
  1141
    */
sl@0
  1142
    inline TInt GetOtgFeatures(TUint8& aFeatures);
sl@0
  1143
sl@0
  1144
    /** Register for notification on USB on-the-go features' change. If any OTG feature
sl@0
  1145
        is changed, request completes and current feature value is filled in aValue.
sl@0
  1146
sl@0
  1147
        @param aStatus Request status object
sl@0
  1148
        @param aValue On request completion, it contains current OTG feature value
sl@0
  1149
    */
sl@0
  1150
    inline void OtgFeaturesNotify(TRequestStatus& aStatus, TUint8& aValue);
sl@0
  1151
sl@0
  1152
    /** Cancel pending OTG feature request.
sl@0
  1153
    */
sl@0
  1154
    inline void OtgFeaturesNotifyCancel();
sl@0
  1155
sl@0
  1156
#endif // #ifndef __KERNEL_MODE__
sl@0
  1157
	};
sl@0
  1158
sl@0
  1159
sl@0
  1160
#include <d32usbc.inl>
sl@0
  1161
sl@0
  1162
sl@0
  1163
#endif // __D32USBC_H__