1 /** |
1 /** |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
28 |
28 |
29 #include <e32std.h> |
29 #include <e32std.h> |
30 #include "MUsbDeviceNotify.h" |
30 #include "MUsbDeviceNotify.h" |
31 #include <usb/usbshared.h> |
31 #include <usb/usbshared.h> |
32 |
32 |
|
33 #include "musbdevicenotifyinternal.h" |
|
34 |
33 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
35 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
34 #include "musbotghostnotifyobserver.h" |
36 #include "musbotghostnotifyobserver.h" |
35 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
37 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
36 |
38 |
37 // device event queue size is number of device states + 1 |
39 // device event queue size is number of device states + 1 |
38 // (+1 so we can distinguish full & empty!) |
40 // (+1 so we can distinguish full & empty!) |
39 // (any state can only appear in the queue once) |
41 // (any state can only appear in the queue once) |
40 const TInt KDeviceStatesQueueSize = KUsbDeviceStates + 1; |
42 const TInt KDeviceStatesQueueSize = KUsbDeviceStates + 1; |
41 const TInt KOtgHostMessageQueueSize = KDeviceStatesQueueSize * 2; |
43 const TInt KOtgHostMessageQueueSize = KDeviceStatesQueueSize * 2; |
42 |
44 const TInt KUsbThermalStateSize = 5; |
43 // |
45 // |
44 // Forward declarations |
46 // Forward declarations |
45 // |
47 // |
46 class CUsbServer; |
48 class CUsbServer; |
47 |
49 |
49 * The CUsbSession class |
51 * The CUsbSession class |
50 * |
52 * |
51 * Implements a Session of a Symbian OS server for the RUsb API |
53 * Implements a Session of a Symbian OS server for the RUsb API |
52 */ |
54 */ |
53 NONSHARABLE_CLASS(CUsbSession) : public CSession2 |
55 NONSHARABLE_CLASS(CUsbSession) : public CSession2 |
54 , public MUsbDeviceNotify |
56 , public MUsbDeviceNotifyInternal |
55 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
57 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
56 , public MUsbOtgHostNotifyObserver |
58 , public MUsbOtgHostNotifyObserver |
57 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
59 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
58 { |
60 { |
59 public: |
61 public: |
62 |
64 |
63 // CSession2 |
65 // CSession2 |
64 virtual void ServiceL(const RMessage2& aMessage); |
66 virtual void ServiceL(const RMessage2& aMessage); |
65 virtual void CreateL(); |
67 virtual void CreateL(); |
66 |
68 |
67 // MUsbDeviceNotify |
69 // MUsbDeviceNotifyInternal |
68 virtual void UsbDeviceStateChange(TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState); |
70 virtual void UsbDeviceStateChange(TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState); |
69 virtual void UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, TUsbServiceState aNewState); |
71 virtual void UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, TUsbServiceState aNewState); |
70 |
72 virtual void UsbThermalStateChange(TInt aLastError, TInt aNewValue); |
|
73 |
71 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
74 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
72 // MUsbOtgHostNotifyObserver |
75 // MUsbOtgHostNotifyObserver |
73 virtual void UsbOtgHostMessage(TInt aMessage); |
76 virtual void UsbOtgHostMessage(TInt aMessage); |
74 virtual void UsbHostEvent(TDeviceEventInformation& aDevInfo); |
77 virtual void UsbHostEvent(TDeviceEventInformation& aDevInfo); |
75 |
78 |
106 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
109 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
107 // Common functions |
110 // Common functions |
108 TInt SetCtlSessionMode(const RMessage2& aMessage); |
111 TInt SetCtlSessionMode(const RMessage2& aMessage); |
109 TInt RegisterMsgObserver(const RMessage2& aMessage, TBool& aComplete); |
112 TInt RegisterMsgObserver(const RMessage2& aMessage, TBool& aComplete); |
110 TInt DeRegisterMsgObserver(); |
113 TInt DeRegisterMsgObserver(); |
111 |
114 |
|
115 // Thermal info |
|
116 void ForwardThermalMessage(); |
|
117 |
112 // OTG |
118 // OTG |
113 TInt BusRequest(); |
119 TInt BusRequest(); |
114 TInt BusRespondSrp(); |
120 TInt BusRespondSrp(); |
115 |
121 |
116 TInt BusClearError(); |
122 TInt BusClearError(); |
159 TBool iDeviceObserverOutstanding; |
165 TBool iDeviceObserverOutstanding; |
160 TBool iServiceObserverOutstanding; |
166 TBool iServiceObserverOutstanding; |
161 TBool iPersonalityCfged; |
167 TBool iPersonalityCfged; |
162 |
168 |
163 TFixedArray<TUsbDeviceState, KDeviceStatesQueueSize> iDeviceStateQueue; |
169 TFixedArray<TUsbDeviceState, KDeviceStatesQueueSize> iDeviceStateQueue; |
|
170 |
164 TUsbDeviceState iNotifiedDevState; |
171 TUsbDeviceState iNotifiedDevState; |
165 TBool iObserverQueueEvents; |
172 TBool iObserverQueueEvents; |
166 TInt iDevStateQueueHead; |
173 TInt iDevStateQueueHead; |
167 TInt iDevStateQueueTail; |
174 TInt iDevStateQueueTail; |
168 |
175 |
169 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
176 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
170 static CUsbSession* iCtlSession; |
177 static CUsbSession* iCtlSession; |
171 TBool iSessionCtlMode; |
178 TBool iSessionCtlMode; |
172 |
179 TInt iUsbThermalLevel; |
|
180 TBool iThernalLevelMsgPending; |
|
181 |
173 RMessage2 iMsgObserverMessage; |
182 RMessage2 iMsgObserverMessage; |
174 TBool iMsgObserverOutstanding; |
183 TBool iMsgObserverOutstanding; |
175 TFixedArray<TInt, KOtgHostMessageQueueSize> iMsgQueue; |
184 TFixedArray<TInt, KOtgHostMessageQueueSize> iMsgQueue; |
176 TBool iMsgObserverQueueEvents; |
185 TBool iMsgObserverQueueEvents; |
177 TInt iMsgQueueHead; |
186 TInt iMsgQueueHead; |