author | Mike Kinghan <mikek@symbian.org> |
Wed, 21 Jul 2010 12:04:49 +0100 | |
branch | GCC_SURGE |
changeset 215 | 8096a832df02 |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2000-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 |
// e32test/usb/t_usb_device/src/activestatenotifier.cpp |
|
15 |
// USB Test Program T_USB_DEVICE, functional part. |
|
16 |
// Device-side part, to work against T_USB_HOST running on the host. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
#include "general.h" |
|
21 |
#include "activerw.h" // CActiveRW |
|
22 |
#include "config.h" |
|
215
8096a832df02
Fix for bug 3322 - Non-portable case-sensitivity and path-delimiter fluff in e32test build
Mike Kinghan <mikek@symbian.org>
parents:
90
diff
changeset
|
23 |
#include "activecontrol.h" |
0 | 24 |
#include "activedevicestatenotifier.h" |
25 |
||
26 |
extern CActiveControl* gActiveControl; |
|
27 |
extern RTest test; |
|
28 |
extern TBool gVerbose; |
|
29 |
extern TBool gSkip; |
|
30 |
extern TBool gStopOnFail; |
|
31 |
extern TBool gAltSettingOnNotify; |
|
32 |
extern TInt gSoakCount; |
|
33 |
extern CActiveRW* gRW[KMaxConcurrentTests]; // the USB read/write active object |
|
34 |
extern IFConfigPtr gInterfaceConfig [128] [KMaxInterfaceSettings]; |
|
35 |
||
36 |
// |
|
37 |
// --- class CActiveDeviceStateNotifier --------------------------------------------------------- |
|
38 |
// |
|
39 |
||
40 |
CActiveDeviceStateNotifier::CActiveDeviceStateNotifier(CConsoleBase* aConsole, RDEVCLIENT* aPort, TUint aPortNumber) |
|
41 |
: CActive(EPriorityNormal), |
|
42 |
iConsole(aConsole), |
|
43 |
iPort(aPort), |
|
44 |
iDeviceState(0), |
|
45 |
iPortNumber(aPortNumber) |
|
46 |
{ |
|
47 |
CActiveScheduler::Add(this); |
|
48 |
} |
|
49 |
||
50 |
CActiveDeviceStateNotifier* CActiveDeviceStateNotifier::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort, TUint aPortNumber) |
|
51 |
{ |
|
52 |
CActiveDeviceStateNotifier* self = new (ELeave) CActiveDeviceStateNotifier(aConsole, aPort, aPortNumber); |
|
53 |
CleanupStack::PushL(self); |
|
54 |
self->ConstructL(); |
|
55 |
CleanupStack::Pop(); // self |
|
56 |
return self; |
|
57 |
} |
|
58 |
||
59 |
||
60 |
void CActiveDeviceStateNotifier::ConstructL() |
|
61 |
{} |
|
62 |
||
63 |
||
64 |
CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
|
65 |
{ |
|
66 |
TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
|
67 |
Cancel(); // base class |
|
68 |
} |
|
69 |
||
70 |
||
71 |
void CActiveDeviceStateNotifier::DoCancel() |
|
72 |
{ |
|
73 |
TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::DoCancel()"); |
|
74 |
iPort->AlternateDeviceStatusNotifyCancel(); |
|
75 |
} |
|
76 |
||
77 |
||
78 |
void CActiveDeviceStateNotifier::RunL() |
|
79 |
{ |
|
80 |
// This displays the device state. |
|
81 |
// In a real world program, the user could take here appropriate action (cancel a |
|
82 |
// transfer request or whatever). |
|
83 |
if (!(iDeviceState & KUsbAlternateSetting) && gVerbose) |
|
84 |
{ |
|
85 |
switch (iDeviceState) |
|
86 |
{ |
|
87 |
case EUsbcDeviceStateUndefined: |
|
88 |
TUSB_PRINT("Device State notifier: Undefined"); |
|
89 |
break; |
|
90 |
case EUsbcDeviceStateAttached: |
|
91 |
TUSB_PRINT("Device State notifier: Attached"); |
|
92 |
break; |
|
93 |
case EUsbcDeviceStatePowered: |
|
94 |
TUSB_PRINT("Device State notifier: Powered"); |
|
95 |
break; |
|
96 |
case EUsbcDeviceStateDefault: |
|
97 |
TUSB_PRINT("Device State notifier: Default"); |
|
98 |
break; |
|
99 |
case EUsbcDeviceStateAddress: |
|
100 |
TUSB_PRINT("Device State notifier: Address"); |
|
101 |
break; |
|
102 |
case EUsbcDeviceStateConfigured: |
|
103 |
TUSB_PRINT("Device State notifier: Configured"); |
|
104 |
break; |
|
105 |
case EUsbcDeviceStateSuspended: |
|
106 |
TUSB_PRINT("Device State notifier: Suspended"); |
|
107 |
break; |
|
108 |
default: |
|
109 |
TUSB_PRINT("Device State notifier: ***BAD***"); |
|
110 |
} |
|
111 |
} |
|
112 |
else if (iDeviceState & KUsbAlternateSetting) |
|
113 |
{ |
|
114 |
TUint8 altSetting = iDeviceState & ~KUsbAlternateSetting; |
|
115 |
TUSB_PRINT2("Device State notifier: Alternate interface %d setting has changed: now %d", |
|
116 |
iPortNumber, altSetting); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
TUsbDeviceCaps dCaps; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
iPort->DeviceCaps(dCaps); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
TBool isResourceAllocationV2 = ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
if (!isResourceAllocationV2) |
0 | 122 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
// allocate endpoint DMA and double buffering for all endpoints on interface for resource allocation v1 |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
// if resource allocation v2, refer to CActiveControl::ConstructL and CActiveControl::PopulateInterfaceResourceAllocation |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
for (TUint8 ifNumber = 0; ifNumber < 128; ifNumber++) |
0 | 126 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
IFConfigPtr newIfPtr = gInterfaceConfig[ifNumber][altSetting]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
if (newIfPtr) |
0 | 129 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
if (newIfPtr->iPortNumber == iPortNumber) |
0 | 131 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
// allocate endpoint DMA and double buffering for all endpoints on default interface |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
for (TUint8 i = 1; i <= newIfPtr->iInfoPtr->iTotalEndpointsUsed; i++) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
newIfPtr->iEpDMA[i-1] ? gActiveControl->AllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateEndpointDMA(iPort,(TENDPOINTNUMBER)i); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
#ifndef USB_SC |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
newIfPtr->iEpDoubleBuff[i-1] ? gActiveControl->AllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i) : gActiveControl->DeAllocateDoubleBuffering(iPort,(TENDPOINTNUMBER)i); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
#endif |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
break; |
0 | 141 |
} |
142 |
} |
|
143 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
|
0 | 146 |
if (gAltSettingOnNotify) |
147 |
{ |
|
148 |
for (TUint16 i =0; i < KMaxConcurrentTests; i++) |
|
149 |
{ |
|
150 |
if (gRW[i]) |
|
151 |
{ |
|
152 |
TUSB_VERBOSE_PRINT1("Resuming alternate Setting - activeRW index %d",i); |
|
153 |
gRW[i]->ResumeAltSetting(altSetting); |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
158 |
Activate(); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
void CActiveDeviceStateNotifier::Activate() |
|
163 |
{ |
|
164 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 661)); |
|
165 |
iPort->AlternateDeviceStatusNotify(iStatus, iDeviceState); |
|
166 |
SetActive(); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
// -eof- |