12 // |
12 // |
13 // Description: |
13 // Description: |
14 // e32test/usb/t_usb_device/src/activestatenotifier.cpp |
14 // e32test/usb/t_usb_device/src/activestatenotifier.cpp |
15 // USB Test Program T_USB_DEVICE, functional part. |
15 // USB Test Program T_USB_DEVICE, functional part. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
17 // |
17 // |
18 // |
18 // |
19 |
19 |
20 #include "general.h" |
20 #include "general.h" |
21 #include "activerw.h" // CActiveRW |
21 #include "activerw.h" // CActiveRW |
22 #include "config.h" |
22 #include "config.h" |
23 #include "activeControl.h" |
23 #include "activeControl.h" |
|
24 #include "OstTraceDefinitions.h" |
|
25 #ifdef OST_TRACE_COMPILER_IN_USE |
|
26 #include "activedevicestatenotifierTraces.h" |
|
27 #endif |
24 #include "activedevicestatenotifier.h" |
28 #include "activedevicestatenotifier.h" |
25 |
29 |
26 extern CActiveControl* gActiveControl; |
30 extern CActiveControl* gActiveControl; |
27 extern RTest test; |
31 extern RTest test; |
28 extern TBool gVerbose; |
32 extern TBool gVerbose; |
62 |
66 |
63 |
67 |
64 CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
68 CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
65 { |
69 { |
66 TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
70 TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
|
71 if(gVerbose) |
|
72 { |
|
73 OstTrace0(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_DCACTIVEDEVICESTATENOTIFIER, "CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
|
74 } |
67 Cancel(); // base class |
75 Cancel(); // base class |
68 } |
76 } |
69 |
77 |
70 |
78 |
71 void CActiveDeviceStateNotifier::DoCancel() |
79 void CActiveDeviceStateNotifier::DoCancel() |
72 { |
80 { |
73 TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::DoCancel()"); |
81 TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::DoCancel()"); |
|
82 if(gVerbose) |
|
83 { |
|
84 OstTrace0(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_DOCANCEL, "CActiveDeviceStateNotifier::DoCancel()"); |
|
85 } |
74 iPort->AlternateDeviceStatusNotifyCancel(); |
86 iPort->AlternateDeviceStatusNotifyCancel(); |
75 } |
87 } |
76 |
88 |
77 |
89 |
78 void CActiveDeviceStateNotifier::RunL() |
90 void CActiveDeviceStateNotifier::RunL() |
85 switch (iDeviceState) |
97 switch (iDeviceState) |
86 { |
98 { |
87 case EUsbcDeviceStateUndefined: |
99 case EUsbcDeviceStateUndefined: |
88 #ifdef USB_SC |
100 #ifdef USB_SC |
89 TUSB_PRINT("Device State notifier: Undefined0"); |
101 TUSB_PRINT("Device State notifier: Undefined0"); |
|
102 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL, "Device State notifier: Undefined0"); |
90 for (TUint16 i =0; i < KMaxConcurrentTests; i++) |
103 for (TUint16 i =0; i < KMaxConcurrentTests; i++) |
91 { |
104 { |
92 if (gRW[i]) |
105 if (gRW[i]) |
93 { |
106 { |
94 TUSB_VERBOSE_PRINT2("ResetAltSetting index %d, LDD %x",i, gRW[i]->Ldd()); |
107 TUSB_VERBOSE_PRINT2("ResetAltSetting index %d, LDD %x",i, gRW[i]->Ldd()); |
95 gRW[i]->Ldd()->ResetAltSetting(); |
108 if(gVerbose) |
|
109 { |
|
110 OstTraceExt2(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP01, "ResetAltSetting index %u, LDD %x",(TUint32)i, (TUint32)gRW[i]->Ldd()); |
|
111 } |
|
112 gRW[i]->Ldd()->ResetAltSetting(); |
96 } |
113 } |
97 } |
114 } |
98 #endif |
115 #endif |
99 TUSB_PRINT("Device State notifier: Undefined"); |
116 TUSB_PRINT("Device State notifier: Undefined"); |
|
117 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP02, "Device State notifier: Undefined"); |
100 break; |
118 break; |
101 case EUsbcDeviceStateAttached: |
119 case EUsbcDeviceStateAttached: |
102 TUSB_PRINT("Device State notifier: Attached"); |
120 TUSB_PRINT("Device State notifier: Attached"); |
|
121 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP03, "Device State notifier: Attached"); |
103 break; |
122 break; |
104 case EUsbcDeviceStatePowered: |
123 case EUsbcDeviceStatePowered: |
105 TUSB_PRINT("Device State notifier: Powered"); |
124 TUSB_PRINT("Device State notifier: Powered"); |
|
125 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP04, "Device State notifier: Powered"); |
106 break; |
126 break; |
107 case EUsbcDeviceStateDefault: |
127 case EUsbcDeviceStateDefault: |
108 TUSB_PRINT("Device State notifier: Default"); |
128 TUSB_PRINT("Device State notifier: Default"); |
|
129 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP05, "Device State notifier: Default"); |
109 break; |
130 break; |
110 case EUsbcDeviceStateAddress: |
131 case EUsbcDeviceStateAddress: |
111 TUSB_PRINT("Device State notifier: Address"); |
132 TUSB_PRINT("Device State notifier: Address"); |
|
133 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP06, "Device State notifier: Address"); |
112 break; |
134 break; |
113 case EUsbcDeviceStateConfigured: |
135 case EUsbcDeviceStateConfigured: |
114 TUSB_PRINT("Device State notifier: Configured"); |
136 TUSB_PRINT("Device State notifier: Configured"); |
|
137 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP07, "Device State notifier: Configured"); |
115 break; |
138 break; |
116 case EUsbcDeviceStateSuspended: |
139 case EUsbcDeviceStateSuspended: |
117 TUSB_PRINT("Device State notifier: Suspended"); |
140 TUSB_PRINT("Device State notifier: Suspended"); |
|
141 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP08, "Device State notifier: Suspended"); |
118 break; |
142 break; |
119 default: |
143 default: |
120 TUSB_PRINT("Device State notifier: ***BAD***"); |
144 TUSB_PRINT("Device State notifier: ***BAD***"); |
|
145 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP09, "Device State notifier: ***BAD***"); |
121 } |
146 } |
122 } |
147 } |
123 else if (iDeviceState & KUsbAlternateSetting) |
148 else if (iDeviceState & KUsbAlternateSetting) |
124 { |
149 { |
125 TUint8 altSetting = iDeviceState & ~KUsbAlternateSetting; |
150 TUint8 altSetting = iDeviceState & ~KUsbAlternateSetting; |
126 TUSB_PRINT2("Device State notifier: Alternate interface %d setting has changed: now %d", |
151 TUSB_PRINT2("Device State notifier: Alternate interface %d setting has changed: now %d", |
127 iPortNumber, altSetting); |
152 iPortNumber, altSetting); |
128 |
153 OstTraceExt2(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP10, "Device State notifier: Alternate interface %u setting has changed: now %u", |
|
154 (TUint32)iPortNumber, (TUint32)altSetting); |
|
155 |
129 TUsbDeviceCaps dCaps; |
156 TUsbDeviceCaps dCaps; |
130 iPort->DeviceCaps(dCaps); |
157 iPort->DeviceCaps(dCaps); |
131 TBool isResourceAllocationV2 = ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
158 TBool isResourceAllocationV2 = ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
132 if (!isResourceAllocationV2) |
159 if (!isResourceAllocationV2) |
133 { |
160 { |
146 newIfPtr->iEpDMA[i-1] ? gActiveControl->AllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i); |
173 newIfPtr->iEpDMA[i-1] ? gActiveControl->AllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i); |
147 #ifndef USB_SC |
174 #ifndef USB_SC |
148 newIfPtr->iEpDoubleBuff[i-1] ? gActiveControl->AllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i); |
175 newIfPtr->iEpDoubleBuff[i-1] ? gActiveControl->AllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i); |
149 #endif |
176 #endif |
150 } |
177 } |
151 break; |
178 break; |
152 } |
179 } |
153 } |
180 } |
154 } |
181 } |
155 } |
182 } |
156 |
183 |
157 if (gAltSettingOnNotify) |
184 if (gAltSettingOnNotify) |
158 { |
185 { |
159 for (TUint16 i =0; i < KMaxConcurrentTests; i++) |
186 for (TUint16 i =0; i < KMaxConcurrentTests; i++) |
160 { |
187 { |
161 if (gRW[i]) |
188 if (gRW[i]) |
162 { |
189 { |
163 TUSB_VERBOSE_PRINT1("Resuming alternate Setting - activeRW index %d",i); |
190 TUSB_VERBOSE_PRINT1("Resuming alternate Setting - activeRW index %d",i); |
164 gRW[i]->ResumeAltSetting(altSetting); |
191 if(gVerbose) |
|
192 { |
|
193 OstTrace1(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP11, "Resuming alternate Setting - activeRW index %d",i); |
|
194 } |
|
195 gRW[i]->ResumeAltSetting(altSetting); |
165 } |
196 } |
166 } |
197 } |
167 } |
198 } |
168 } |
199 } |
169 Activate(); |
200 Activate(); |