74 */ |
73 */ |
75 CUsbWHCMClassController::CUsbWHCMClassController( |
74 CUsbWHCMClassController::CUsbWHCMClassController( |
76 MUsbClassControllerNotify& aOwner) |
75 MUsbClassControllerNotify& aOwner) |
77 : CUsbClassControllerPlugIn(aOwner, KWHCMPriority) |
76 : CUsbClassControllerPlugIn(aOwner, KWHCMPriority) |
78 { |
77 { |
|
78 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_CUSBWHCMCLASSCONTROLLER_CONS_ENTRY ); |
79 iState = EUsbServiceIdle; |
79 iState = EUsbServiceIdle; |
|
80 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_CUSBWHCMCLASSCONTROLLER_CONS_EXIT ); |
80 } |
81 } |
81 |
82 |
82 /** |
83 /** |
83 * Method to perform second phase construction. |
84 * Method to perform second phase construction. |
84 */ |
85 */ |
85 void CUsbWHCMClassController::ConstructL() |
86 void CUsbWHCMClassController::ConstructL() |
86 { |
87 { |
|
88 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_CONSTRUCTL_ENTRY ); |
87 // Load the device driver |
89 // Load the device driver |
88 TInt err = User::LoadLogicalDevice(KUsbLDDName); |
90 TInt err = User::LoadLogicalDevice(KUsbLDDName); |
89 if (err != KErrNone && err != KErrAlreadyExists) |
91 if (err != KErrNone && err != KErrAlreadyExists) |
90 { |
92 { |
91 LEAVEL(err); |
93 OstTrace1( TRACE_NORMAL, CUSBWHCMCLASSCONTROLLER_CONSTRUCTL, |
|
94 "CUsbWHCMClassController::ConstructL;err=%d", err ); |
|
95 User::Leave(err); |
92 } |
96 } |
93 |
97 |
94 LEAVEIFERRORL(iLdd.Open(0)); |
98 |
|
99 err = iLdd.Open(0); |
|
100 if (err < 0) |
|
101 { |
|
102 OstTrace1( TRACE_NORMAL, CUSBWHCMCLASSCONTROLLER_CONSTRUCTL_DUP1, |
|
103 "CUsbWHCMClassController::ConstructL;err=%d", err ); |
|
104 User::Leave(err); |
|
105 } |
|
106 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_CONSTRUCTL_EXIT ); |
95 } |
107 } |
96 |
108 |
97 /** |
109 /** |
98 * Destructor. |
110 * Destructor. |
99 */ |
111 */ |
100 CUsbWHCMClassController::~CUsbWHCMClassController() |
112 CUsbWHCMClassController::~CUsbWHCMClassController() |
101 { |
113 { |
|
114 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_CUSBWHCMCLASSCONTROLLER_DES_ENTRY ); |
102 Cancel(); |
115 Cancel(); |
103 |
|
104 if (iState == EUsbServiceStarted) |
116 if (iState == EUsbServiceStarted) |
105 { |
117 { |
106 // Must release all interfaces before closing the LDD to avoid a crash. |
118 // Must release all interfaces before closing the LDD to avoid a crash. |
107 iLdd.ReleaseInterface(0); |
119 iLdd.ReleaseInterface(0); |
108 } |
120 } |
109 iLdd.Close(); |
121 iLdd.Close(); |
|
122 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_CUSBWHCMCLASSCONTROLLER_DES_EXIT ); |
110 } |
123 } |
111 |
124 |
112 /** |
125 /** |
113 * Called by UsbMan to start this class. |
126 * Called by UsbMan to start this class. |
114 * |
127 * |
115 * @param aStatus Will be completed with success or failure. |
128 * @param aStatus Will be completed with success or failure. |
116 */ |
129 */ |
117 void CUsbWHCMClassController::Start(TRequestStatus& aStatus) |
130 void CUsbWHCMClassController::Start(TRequestStatus& aStatus) |
118 { |
131 { |
119 LOG_FUNC |
132 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_START_ENTRY ); |
120 |
133 |
121 //Start() should never be called if started, starting or stopping (or in state EUsbServiceFatalError) |
134 //Start() should never be called if started, starting or stopping (or in state EUsbServiceFatalError) |
122 __ASSERT_DEBUG( iState == EUsbServiceIdle, _USB_PANIC(KWhcmCcPanicCategory, EBadApiCallStart) ); |
135 if (iState != EUsbServiceIdle) |
|
136 { |
|
137 OstTrace1( TRACE_FATAL, CUSBWHCMCLASSCONTROLLER_START, "CUsbWHCMClassController::Start;iState=%d", (TInt)iState ); |
|
138 __ASSERT_DEBUG( EFalse, User::Panic(KWhcmCcPanicCategory, EBadApiCallStart) ); |
|
139 } |
123 |
140 |
124 TRequestStatus* reportStatus = &aStatus; |
141 TRequestStatus* reportStatus = &aStatus; |
125 |
142 |
126 iState = EUsbServiceStarting; |
143 iState = EUsbServiceStarting; |
127 |
|
128 TRAPD(err, SetUpWHCMDescriptorL()); |
144 TRAPD(err, SetUpWHCMDescriptorL()); |
129 |
|
130 if (err != KErrNone) |
145 if (err != KErrNone) |
131 { |
146 { |
132 iState = EUsbServiceIdle; |
147 iState = EUsbServiceIdle; |
133 User::RequestComplete(reportStatus, err); |
148 User::RequestComplete(reportStatus, err); |
|
149 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_START_EXIT ); |
134 return; |
150 return; |
135 } |
151 } |
136 iState = EUsbServiceStarted; |
152 iState = EUsbServiceStarted; |
137 User::RequestComplete(reportStatus, KErrNone); |
153 User::RequestComplete(reportStatus, KErrNone); |
|
154 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_START_EXIT_DUP1 ); |
138 } |
155 } |
139 |
156 |
140 /** |
157 /** |
141 * Called by UsbMan to stop this class. |
158 * Called by UsbMan to stop this class. |
142 * |
159 * |
143 * @param aStatus Will be completed with success or failure. |
160 * @param aStatus Will be completed with success or failure. |
144 */ |
161 */ |
145 void CUsbWHCMClassController::Stop(TRequestStatus& aStatus) |
162 void CUsbWHCMClassController::Stop(TRequestStatus& aStatus) |
146 { |
163 { |
147 LOG_FUNC |
164 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_STOP_ENTRY ); |
148 |
165 |
149 //Stop() should never be called if stopping, idle or starting (or in state EUsbServiceFatalError) |
166 //Stop() should never be called if stopping, idle or starting (or in state EUsbServiceFatalError) |
150 __ASSERT_DEBUG( iState == EUsbServiceStarted, _USB_PANIC(KWhcmCcPanicCategory, EBadApiCallStop) ); |
167 if (iState != EUsbServiceStarted) |
|
168 { |
|
169 OstTrace1( TRACE_FATAL, CUSBWHCMCLASSCONTROLLER_STOP, "CUsbWHCMClassController::Stop;iState=%d", (TInt)iState ); |
|
170 __ASSERT_DEBUG( EFalse, User::Panic(KWhcmCcPanicCategory, EBadApiCallStart) ); |
|
171 } |
151 |
172 |
152 TRequestStatus* reportStatus = &aStatus; |
173 TRequestStatus* reportStatus = &aStatus; |
153 |
174 |
154 // Must release all interfaces before closing the LDD to avoid a crash. |
175 // Must release all interfaces before closing the LDD to avoid a crash. |
155 iLdd.ReleaseInterface(0); |
176 iLdd.ReleaseInterface(0); |
157 iState = EUsbServiceIdle; |
178 iState = EUsbServiceIdle; |
158 |
179 |
159 aStatus = KRequestPending; |
180 aStatus = KRequestPending; |
160 |
181 |
161 User::RequestComplete(reportStatus, KErrNone); |
182 User::RequestComplete(reportStatus, KErrNone); |
|
183 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_STOP_EXIT ); |
162 } |
184 } |
163 |
185 |
164 /** |
186 /** |
165 * Returns information about the interfaces supported by this class. |
187 * Returns information about the interfaces supported by this class. |
166 * |
188 * |
167 * @param aDescriptorInfo Will be filled in with interface information. |
189 * @param aDescriptorInfo Will be filled in with interface information. |
168 */ |
190 */ |
169 void CUsbWHCMClassController::GetDescriptorInfo( |
191 void CUsbWHCMClassController::GetDescriptorInfo( |
170 TUsbDescriptor& /*aDescriptorInfo*/) const |
192 TUsbDescriptor& /*aDescriptorInfo*/) const |
171 { |
193 { |
|
194 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_GETDESCRIPTORINFO_ENTRY ); |
|
195 OstTraceFunctionExit0( CUSBWHCMCLASSCONTROLLER_GETDESCRIPTORINFO_EXIT ); |
172 } |
196 } |
173 |
197 |
174 /** |
198 /** |
175 * Standard active object RunL. |
199 * Standard active object RunL. |
176 */ |
200 */ |
177 void CUsbWHCMClassController::RunL() |
201 void CUsbWHCMClassController::RunL() |
178 { |
202 { |
179 // This function should never be called. |
203 // This function should never be called. |
180 _USB_PANIC(KWhcmCcPanicCategory, EUnusedFunction); |
204 OstTrace0( TRACE_FATAL, CUSBWHCMCLASSCONTROLLER_RUNL, "CUsbWHCMClassController::RunL;EUnusedFunction"); |
|
205 User::Panic(KWhcmCcPanicCategory, EUnusedFunction); |
181 } |
206 } |
182 |
207 |
183 /** |
208 /** |
184 * Standard active object cancellation function. Will only be called when an |
209 * Standard active object cancellation function. Will only be called when an |
185 * asynchronous request is currently active. |
210 * asynchronous request is currently active. |
186 */ |
211 */ |
187 void CUsbWHCMClassController::DoCancel() |
212 void CUsbWHCMClassController::DoCancel() |
188 { |
213 { |
189 // This function should never be called. |
214 // This function should never be called. |
190 _USB_PANIC(KWhcmCcPanicCategory, EUnusedFunction); |
215 OstTrace0( TRACE_FATAL, CUSBWHCMCLASSCONTROLLER_DOCANCEL, "CUsbWHCMClassController::DoCancel;EUnusedFunction"); |
|
216 User::Panic(KWhcmCcPanicCategory, EUnusedFunction); |
191 } |
217 } |
192 |
218 |
193 /** |
219 /** |
194 * Standard active object error-handling function. Should return KErrNone to |
220 * Standard active object error-handling function. Should return KErrNone to |
195 * avoid an active scheduler panic. |
221 * avoid an active scheduler panic. |
196 */ |
222 */ |
197 TInt CUsbWHCMClassController::RunError(TInt /*aError*/) |
223 TInt CUsbWHCMClassController::RunError(TInt /*aError*/) |
198 { |
224 { |
199 // This function should never be called. |
225 // This function should never be called. |
200 _USB_PANIC(KWhcmCcPanicCategory, EUnusedFunction); |
226 OstTrace0( TRACE_FATAL, CUSBWHCMCLASSCONTROLLER_RUNERROR, "CUsbWHCMClassController::RunError;EUnusedFunction"); |
201 |
227 User::Panic(KWhcmCcPanicCategory, EUnusedFunction); |
202 return KErrNone; |
228 return KErrNone; |
203 } |
229 } |
204 |
230 |
205 |
231 |
206 void CUsbWHCMClassController::SetUpWHCMDescriptorL() |
232 void CUsbWHCMClassController::SetUpWHCMDescriptorL() |
207 /** |
233 /** |
208 * Setup the WHCM Class Descriptors. |
234 * Setup the WHCM Class Descriptors. |
209 */ |
235 */ |
210 { |
236 { |
|
237 OstTraceFunctionEntry0( CUSBWHCMCLASSCONTROLLER_SETUPWHCMDESCROPTORL_ENTRY ); |
|
238 |
211 // Set up and register the WHCM interface descriptor |
239 // Set up and register the WHCM interface descriptor |
212 |
240 |
213 TUsbcInterfaceInfoBuf ifc; |
241 TUsbcInterfaceInfoBuf ifc; |
214 ifc().iString = NULL; |
242 ifc().iString = NULL; |
215 ifc().iClass.iClassNum = 0x02; |
243 ifc().iClass.iClassNum = 0x02; |
219 |
247 |
220 // Indicate that this interface does not expect any control transfers |
248 // Indicate that this interface does not expect any control transfers |
221 // from EP0. |
249 // from EP0. |
222 ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease; |
250 ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease; |
223 |
251 |
224 LEAVEIFERRORL(iLdd.SetInterface(0, ifc)); |
252 TInt err = iLdd.SetInterface(0, ifc); |
|
253 if (err < 0) |
|
254 { |
|
255 OstTrace1( TRACE_NORMAL, CUSBWHCMCLASSCONTROLLER_SETUPWHCMDESCROPTORL, |
|
256 "CUsbWHCMClassController::SetUpWHCMDescriptorL;err=%d", (TInt)err ); |
|
257 User::Leave(err); |
|
258 } |
225 |
259 |
226 // Get the interface number from the LDD for later reference |
260 // Get the interface number from the LDD for later reference |
227 TBuf8<100> interface_descriptor; |
261 TBuf8<100> interface_descriptor; |
228 LEAVEIFERRORL(iLdd.GetInterfaceDescriptor(0, interface_descriptor)); |
262 err = iLdd.GetInterfaceDescriptor(0, interface_descriptor); |
|
263 if (err < 0) |
|
264 { |
|
265 OstTrace1( TRACE_NORMAL, CUSBWHCMCLASSCONTROLLER_SETUPWHCMDESCROPTORL_DUP1, |
|
266 "CUsbWHCMClassController::SetUpWHCMDescriptorL;err=%d", (TInt)err ); |
|
267 User::Leave(err); |
|
268 } |
229 |
269 |
230 |
270 |
231 TUint8 WHCM_int_no = interface_descriptor[2]; |
271 TUint8 WHCM_int_no = interface_descriptor[2]; |
232 |
272 |
233 // Set up the class-specific interface block. |
273 // Set up the class-specific interface block. |