|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <kernel.h> |
|
20 #include <mmc.h> |
|
21 #include <locmedia.h> |
|
22 |
|
23 #include "mmcldd.h" |
|
24 #include "d_mmcsdif.h" |
|
25 |
|
26 /** |
|
27 * Do a kernel side control for DMMCPsu |
|
28 * |
|
29 * @param TInt aFunction - Request Function ID |
|
30 * @param TAny* a1 - Given parameter |
|
31 * @param TAny* a2 - Given parameter |
|
32 * |
|
33 * @return TInt the error code |
|
34 * |
|
35 * @leave N/A |
|
36 */ |
|
37 TInt DLddMmcCntrlInterface::PsuDoControl(TInt aFunction, TAny* a1, TAny* a2) |
|
38 { |
|
39 MMCSDLOG("<--PsuDoControl-->"); |
|
40 TInt r = KErrNone; |
|
41 |
|
42 if (!iPsu) |
|
43 { |
|
44 MMCSDLOG("DLddMmcCntrlInterface::PsuDoControl - iPsu is NULL"); |
|
45 return KErrGeneral; |
|
46 } |
|
47 else if (!iClient) |
|
48 { |
|
49 MMCSDLOG("DLddMmcCntrlInterface::PsuDoControl - iClient is NULL"); |
|
50 return KErrGeneral; |
|
51 } |
|
52 |
|
53 switch(TTCFunctionId(aFunction).FunctionId()) |
|
54 { |
|
55 case RMMCSDTestControllerInterface::EPsu: |
|
56 { |
|
57 r = Kern::ThreadRawWrite(iClient, a1, &iPsu, sizeof(iPsu)); |
|
58 } |
|
59 break; |
|
60 case RMMCSDTestControllerInterface::EPsuInfo: |
|
61 { |
|
62 TPBusPsuInfo psuInfo; |
|
63 MMCSDLOG("<--PsuInfo-->"); |
|
64 iPsu->PsuInfo(psuInfo); |
|
65 r = Kern::ThreadRawWrite(iClient, a1, &psuInfo, sizeof(TPBusPsuInfo)); |
|
66 break; |
|
67 } |
|
68 case RMMCSDTestControllerInterface::EPsuState: |
|
69 { |
|
70 if(iPsu != NULL) |
|
71 { |
|
72 TPBusPsuState aState; |
|
73 aState = (TPBusPsuState&)a1; |
|
74 r= iPsu->SetState(aState); |
|
75 MMCSDLOG2("EPsuState :%d", aState); |
|
76 } |
|
77 else |
|
78 { |
|
79 r= KErrGeneral; |
|
80 } |
|
81 break; |
|
82 } |
|
83 case RMMCSDTestControllerInterface::EPsuVoltage: |
|
84 { |
|
85 if(iPsu != NULL) |
|
86 { |
|
87 TUint32 aVoltOpRange; |
|
88 aVoltOpRange = (TUint32)a1; |
|
89 iPsu->SetVoltage(aVoltOpRange); |
|
90 MMCSDLOG2("EPsuVoltage :0x%x", aVoltOpRange); |
|
91 } |
|
92 else |
|
93 { |
|
94 r= KErrGeneral; |
|
95 } |
|
96 break; |
|
97 } |
|
98 case RMMCSDTestControllerInterface::EPsuNum: |
|
99 { |
|
100 if(iPsu != NULL) |
|
101 { |
|
102 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iPsuNum, sizeof(TInt)); |
|
103 MMCSDLOG2("EPsuNum :%d", &iPsu->iPsuNum); |
|
104 } |
|
105 else |
|
106 { |
|
107 r= KErrGeneral; |
|
108 } |
|
109 break; |
|
110 } |
|
111 case RMMCSDTestControllerInterface::EMediaChangeNum: |
|
112 { |
|
113 if(iPsu != NULL) |
|
114 { |
|
115 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iMediaChangeNum, sizeof(TInt)); |
|
116 MMCSDLOG2("EMediaChangeNum :%d", &iPsu->iMediaChangeNum); |
|
117 } |
|
118 else |
|
119 { |
|
120 r= KErrGeneral; |
|
121 } |
|
122 break; |
|
123 } |
|
124 case RMMCSDTestControllerInterface::EPsuCurLimit: |
|
125 { |
|
126 if(iPsu != NULL) |
|
127 { |
|
128 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iCurrLimited, sizeof(TBool)); |
|
129 MMCSDLOG2("EPsuCurLimit :%d", &iPsu->iCurrLimited); |
|
130 } |
|
131 else |
|
132 { |
|
133 r= KErrGeneral; |
|
134 } |
|
135 break; |
|
136 } |
|
137 case RMMCSDTestControllerInterface::EPbusState: |
|
138 { |
|
139 if (iSocket) |
|
140 { |
|
141 r = Kern::ThreadRawWrite(iClient, a1, &iSocket->iState, sizeof(TInt)); |
|
142 MMCSDLOG2("EPbusState :%d", &iSocket->iState); |
|
143 } |
|
144 else |
|
145 { |
|
146 MMCSDLOG("RMMCSDTestControllerInterface::EPbusState - iSocket is NULL"); |
|
147 r = KErrGeneral; |
|
148 } |
|
149 break; |
|
150 } |
|
151 case RMMCSDTestControllerInterface::EVccState: |
|
152 { |
|
153 if(iPsu) |
|
154 { |
|
155 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iState,sizeof(TInt)); |
|
156 MMCSDLOG2("EVccState :%d", &iPsu->iState); |
|
157 } |
|
158 else |
|
159 { |
|
160 r=KErrGeneral; |
|
161 } |
|
162 break; |
|
163 } |
|
164 case RMMCSDTestControllerInterface::EIsLocked: |
|
165 { |
|
166 if(iPsu) |
|
167 { |
|
168 TBool lock =iPsu->IsLocked(); |
|
169 r = Kern::ThreadRawWrite(iClient, a1, &lock,sizeof(TBool)); |
|
170 MMCSDLOG2("EIsLocked :%d", lock); |
|
171 } |
|
172 else |
|
173 { |
|
174 r=KErrGeneral; |
|
175 } |
|
176 break; |
|
177 } |
|
178 case RMMCSDTestControllerInterface::EIsOff: |
|
179 { |
|
180 if(iPsu) |
|
181 { |
|
182 TBool isoff =iPsu->IsOff(); |
|
183 r = Kern::ThreadRawWrite(iClient, a1, &isoff,sizeof(TBool)); |
|
184 MMCSDLOG2("EIsOff :%d", isoff); |
|
185 } |
|
186 else |
|
187 { |
|
188 r=KErrGeneral; |
|
189 } |
|
190 break; |
|
191 } |
|
192 case RMMCSDTestControllerInterface::EMaxCurrentInMicroAmps: |
|
193 { |
|
194 if(iPsu) |
|
195 { |
|
196 TInt current =iPsu->MaxCurrentInMicroAmps(); |
|
197 r = Kern::ThreadRawWrite(iClient, a1, ¤t,sizeof(TInt)); |
|
198 MMCSDLOG2("EMaxCurrentInMicroAmps :%d", current); |
|
199 } |
|
200 else |
|
201 { |
|
202 r=KErrGeneral; |
|
203 } |
|
204 break; |
|
205 } |
|
206 case RMMCSDTestControllerInterface::EResetInactivityTimer: |
|
207 { |
|
208 if(iPsu) |
|
209 { |
|
210 iPsu->ResetInactivityTimer(); |
|
211 MMCSDLOG("EResetInactivityTimer"); |
|
212 } |
|
213 else |
|
214 { |
|
215 r=KErrGeneral; |
|
216 } |
|
217 break; |
|
218 } |
|
219 case RMMCSDTestControllerInterface::EVoltageSupported: |
|
220 { |
|
221 if(iPsu) |
|
222 { |
|
223 TUint vol =iPsu->VoltageSupported(); |
|
224 r = Kern::ThreadRawWrite(iClient, a1, &vol,sizeof(TUint)); |
|
225 MMCSDLOG2("EVoltageSupported :0x%x", vol); |
|
226 } |
|
227 else |
|
228 { |
|
229 r=KErrGeneral; |
|
230 } |
|
231 break; |
|
232 } |
|
233 case RMMCSDTestControllerInterface::EMemInactivityCount: |
|
234 { |
|
235 if(iPsu) |
|
236 { |
|
237 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iInactivityCount,sizeof(&iPsu->iInactivityCount)); |
|
238 MMCSDLOG2("EMemInactivityCount :%d", &iPsu->iInactivityCount); |
|
239 } |
|
240 else |
|
241 { |
|
242 r=KErrGeneral; |
|
243 } |
|
244 break; |
|
245 } |
|
246 case RMMCSDTestControllerInterface::EMemNotLockedCount: |
|
247 { |
|
248 if(iPsu) |
|
249 { |
|
250 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iNotLockedCount,sizeof(&iPsu->iNotLockedCount)); |
|
251 MMCSDLOG2("EMemNotLockedCount :%d", &iPsu->iNotLockedCount); |
|
252 } |
|
253 else |
|
254 { |
|
255 r=KErrGeneral; |
|
256 } |
|
257 break; |
|
258 } |
|
259 case RMMCSDTestControllerInterface::EMemInactivityTimeout: |
|
260 { |
|
261 if(iPsu) |
|
262 { |
|
263 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iInactivityTimeout,sizeof(&iPsu->iInactivityTimeout)); |
|
264 MMCSDLOG2("EMemInactivityTimeout :%d", &iPsu->iInactivityTimeout); |
|
265 } |
|
266 else |
|
267 { |
|
268 r=KErrGeneral; |
|
269 } |
|
270 break; |
|
271 } |
|
272 case RMMCSDTestControllerInterface::EMemNotLockedTimeout: |
|
273 { |
|
274 if(iPsu && iClient) |
|
275 { |
|
276 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iNotLockedTimeout,sizeof(&iPsu->iNotLockedTimeout)); |
|
277 MMCSDLOG2("EMemNotLockedTimeout :%d", &iPsu->iNotLockedTimeout); |
|
278 } |
|
279 else |
|
280 { |
|
281 r=KErrGeneral; |
|
282 } |
|
283 break; |
|
284 } |
|
285 case RMMCSDTestControllerInterface::EMemVoltageSupported: |
|
286 { |
|
287 if(iPsu && iClient) |
|
288 { |
|
289 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iVoltageSupported,sizeof(&iPsu->iVoltageSupported)); |
|
290 MMCSDLOG2("EMemVoltageSupported :%d", &iPsu->iVoltageSupported); |
|
291 } |
|
292 else |
|
293 { |
|
294 r=KErrGeneral; |
|
295 } |
|
296 break; |
|
297 } |
|
298 case RMMCSDTestControllerInterface::EMemMaxCurrentInMicroAmps: |
|
299 { |
|
300 if(iPsu && iClient) |
|
301 { |
|
302 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iMaxCurrentInMicroAmps,sizeof(&iPsu->iMaxCurrentInMicroAmps)); |
|
303 MMCSDLOG2("EMemMaxCurrentInMicroAmps :%d", &iPsu->iMaxCurrentInMicroAmps); |
|
304 } |
|
305 else |
|
306 { |
|
307 r=KErrGeneral; |
|
308 } |
|
309 break; |
|
310 } |
|
311 case RMMCSDTestControllerInterface::EMemVoltCheckInterval: |
|
312 { |
|
313 if(iPsu && iClient) |
|
314 { |
|
315 r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iVoltCheckInterval,sizeof(&iPsu->iVoltCheckInterval)); |
|
316 MMCSDLOG2("EMemVoltCheckInterval :%d", &iPsu->iVoltCheckInterval); |
|
317 } |
|
318 else |
|
319 { |
|
320 r=KErrGeneral; |
|
321 } |
|
322 break; |
|
323 } |
|
324 default: |
|
325 r = KErrNotFound; |
|
326 break; |
|
327 |
|
328 } |
|
329 return (r); |
|
330 } |