kernel/eka/include/d32usbdi_hubdriver.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef D32USBDI_HUBDRIVER_H
       
    17 #define D32USBDI_HUBDRIVER_H
       
    18 
       
    19 #ifdef __KERNEL_MODE__
       
    20 #include <kernel/klib.h>
       
    21 #else
       
    22 #include <e32base.h>
       
    23 #include <d32usbdescriptors.h>
       
    24 #include <e32debug.h>
       
    25 #endif
       
    26 
       
    27 #include <e32ver.h>
       
    28 #include <d32usbdi_errors.h>
       
    29 
       
    30 /**
       
    31 @file
       
    32 @internalComponent
       
    33 @prototype
       
    34 */
       
    35 
       
    36 /*****************************************************************************/
       
    37 /*                                                                           */
       
    38 /* Interface classes                                                         */
       
    39 /*                                                                           */
       
    40 /*****************************************************************************/
       
    41 
       
    42 class RUsbDevice;
       
    43 
       
    44 /**
       
    45 Functions which act on the local hub driver.  Higher level components cannot determine which host controller is in
       
    46  use, although the presence of Other Speed descriptors may give some hints.
       
    47 
       
    48 @note This API is only available to the function driver framework, a restriction which is enforced by checking the
       
    49 SID of the calling process.
       
    50 */
       
    51 class RUsbHubDriver : public RBusLogicalChannel
       
    52 	{
       
    53 public:
       
    54 	enum TUsbHubDriverRequest
       
    55 		{
       
    56 		EWaitForBusEvent,
       
    57 		};
       
    58 	enum TUsbHubDriverControl
       
    59 		{
       
    60 		EStartHost,
       
    61 		EStopHost,
       
    62 		};
       
    63  	enum TUsbHubDriverCancel
       
    64 		{
       
    65 		ECancelWaitForBusEvent	= 0x00000001,
       
    66 		};
       
    67 
       
    68 	class TBusEvent
       
    69 		{
       
    70 	public:
       
    71 		enum TEvent
       
    72 			{
       
    73 			ENoEvent,
       
    74 			EDeviceAttached,
       
    75 			EDeviceRemoved,
       
    76 			EDevMonEvent
       
    77 			};
       
    78 
       
    79 	public:
       
    80 		TEvent	iEventType;
       
    81 		TUint	iDeviceHandle;
       
    82 		TInt	iError;
       
    83 		TInt	iReason;		// When iEventType == EDevMonEvent, this may hold additional details of the reason for the notification
       
    84 		};
       
    85 
       
    86 #ifndef __KERNEL_MODE__
       
    87 friend class RUsbDevice;
       
    88 public:
       
    89 	inline TInt Open();
       
    90 	inline TInt StartHost();
       
    91 	inline void StopHost();
       
    92 
       
    93 	inline void WaitForBusEvent(TBusEvent& aEvent, TRequestStatus& aRequest);
       
    94 	inline void CancelWaitForBusEvent();
       
    95 
       
    96 #endif
       
    97 
       
    98 	inline static const TDesC& Name();
       
    99 	inline static TVersion VersionRequired();
       
   100 	};
       
   101 
       
   102 
       
   103 /**
       
   104 Use restricted to the Function Driver Framework, enforced by SID.
       
   105 Provides a means to examine the configuration descriptor, and so load appropriate Function Drivers.
       
   106 */
       
   107 class RUsbDevice
       
   108 	{
       
   109 public:
       
   110 	enum TUsbDeviceRequest
       
   111 		{
       
   112 		EDeviceRequest		= 0x4000000,   // start at 0x4000000 to differentiate from other requests
       
   113 		EDeviceStateChange,
       
   114 		};
       
   115 	enum TUsbDeviceControl
       
   116 		{
       
   117 		EDeviceControl		= 0x4000000,   // start at 0x4000000 to differentiate from other controls
       
   118 		EOpen,
       
   119 		EClose,
       
   120 		EGetDeviceDescriptor,
       
   121 		EGetConfigurationDescriptorSize,
       
   122 		EGetConfigurationDescriptor,
       
   123 		EGetStringDescriptor,
       
   124 		EGetInterfaceToken,
       
   125 		ESuspend,
       
   126 		EResume,
       
   127 		ECancelDeviceStateChange,
       
   128 		};
       
   129 
       
   130 	enum TDeviceState
       
   131 		{
       
   132 		EDeviceActive,
       
   133 		EDeviceSuspended,
       
   134 		EDeviceTriState,
       
   135 		};
       
   136 	
       
   137 	class TInterfaceTokenParameters
       
   138 		{
       
   139 	public:
       
   140 		TInt		iInterfaceNumber;
       
   141 		TUint32*	iToken;
       
   142 		};
       
   143 	
       
   144 	class TStringDescParams
       
   145 		{
       
   146 	public:
       
   147 		TDes8*		iTarget;
       
   148 		TInt		iIndex;
       
   149 		TInt		iLangId;
       
   150 		};
       
   151 
       
   152 #ifndef __KERNEL_MODE__
       
   153 public:
       
   154 	inline RUsbDevice();
       
   155 
       
   156 	inline TInt Open(RUsbHubDriver& aHub, TUint aHandle);
       
   157 	inline void Close();
       
   158 	
       
   159 	inline void QueueDeviceStateChangeNotification(TDeviceState& aCurrentState, TRequestStatus& aRequest);
       
   160 	inline void CancelDeviceStateChangeNotification();
       
   161 	inline TUint Handle() const;
       
   162 	inline TInt GetTokenForInterface(TInt aInterfaceNumber, TUint32& aToken);
       
   163 
       
   164 	inline TInt Suspend();
       
   165 	inline TInt Resume();
       
   166 
       
   167 	inline TInt GetDeviceDescriptor(TUsbDeviceDescriptor& aDescriptor);
       
   168 	inline TInt GetConfigurationDescriptor(TUsbConfigurationDescriptor& aDescriptor);
       
   169 	inline TInt GetStringDescriptor(TUsbStringDescriptor*& aDescriptor, TDes8& aTarget, TInt aIndex);
       
   170 	inline TInt GetStringDescriptor(TUsbStringDescriptor*& aDescriptor, TDes8& aTarget, TInt aIndex, TInt aLangId);
       
   171 	
       
   172 private:		// Internal function overloads
       
   173 	inline TInt GetDeviceDescriptor(TDes8& aDeviceDesc);
       
   174 	inline TInt GetConfigurationDescriptorSize(TInt& aConfigDescSize);
       
   175 	inline TInt GetConfigurationDescriptor(TDes8& aConfigDesc);
       
   176 	inline TInt GetStringDescriptor(TDes8& aStringDescriptor, TInt aIndex, TInt aLangId =0);
       
   177 	
       
   178 private:
       
   179 	inline void GetLocalDescriptorsL();
       
   180 	inline TInt ParseStringDescriptor(TUsbStringDescriptor*& aDescriptor, const TDesC8& aData);
       
   181 
       
   182 private:
       
   183 	TUsbDeviceDescriptor* iHeadDeviceDescriptor;
       
   184 	TUsbConfigurationDescriptor* iHeadConfDescriptor;
       
   185 
       
   186 	static const TUint KDeviceDescriptorSize = 18;
       
   187 	TBuf8<KDeviceDescriptorSize> iDeviceDescriptorData;
       
   188 	HBufC8* iConfigurationDescriptorData;
       
   189 
       
   190 private:
       
   191 	RUsbHubDriver* iHub;
       
   192 	TUint iHandle;
       
   193 
       
   194 #endif
       
   195 	};
       
   196 
       
   197 
       
   198 #include <d32usbdi_hubdriver.inl>
       
   199 
       
   200 
       
   201 #endif	// D32USBDI_HUBDRIVER_H