18 //#define DEBUG |
18 //#define DEBUG |
19 |
19 |
20 #include <syborg_priv.h> |
20 #include <syborg_priv.h> |
21 #include "syborg_pointer.h" |
21 #include "syborg_pointer.h" |
22 |
22 |
23 TPointerRv::TPointerRv(): |
23 |
24 iRxDfc(RxDfc,this,Kern::DfcQue0(),1) |
24 _LIT(KPointerDfcQNamePre,"PointDFC"); |
|
25 const TInt KDfcQuePriority = 27; |
|
26 |
|
27 |
|
28 |
|
29 TPointerRv::TPointerRv() //sosco : |
|
30 // iRxDfc(RxDfc,this,Kern::DfcQue0(),1) |
|
31 |
25 { |
32 { |
26 __DEBUG_PRINT("TPointerRv::TPointerRv()"); |
33 __DEBUG_PRINT("TPointerRv::TPointerRv()"); |
|
34 |
|
35 |
|
36 TInt err = Kern::DfcQInit(&iDfcQue, KDfcQuePriority, &KPointerDfcQNamePre); |
|
37 if (err) |
|
38 { |
|
39 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::TPointerRv() Error creating dfcq (%d)", err)); |
|
40 } |
|
41 |
|
42 iRxDfc = new TDfc(RxDfc,this,&iDfcQue,1); |
|
43 __ASSERT_ALWAYS(iRxDfc!=NULL,Kern::Printf("Failed to create DFC")); |
|
44 |
|
45 |
27 TInt r = Interrupt::Bind(EIntPointer,Isr,this); |
46 TInt r = Interrupt::Bind(EIntPointer,Isr,this); |
28 if(r != KErrNone) |
47 if(r != KErrNone) |
29 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::TPointerRv() Interrupt::Bind(%d)=%d", |
48 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::TPointerRv() Interrupt::Bind(%d)=%d", |
30 EIntPointer, r)); |
49 EIntPointer, r)); |
31 iPointerOn = ETrue; |
50 iPointerOn = ETrue; |
41 struct TPointerRv::PData* TPointerRv::FifoPop(void) |
60 struct TPointerRv::PData* TPointerRv::FifoPop(void) |
42 { |
61 { |
43 struct TPointerRv::PData* val = &iPDataFifo[iFifoPos]; |
62 struct TPointerRv::PData* val = &iPDataFifo[iFifoPos]; |
44 iFifoPos++; |
63 iFifoPos++; |
45 iFifoCount--; |
64 iFifoCount--; |
46 |
65 |
47 if (iFifoPos == FIFO_SIZE) |
66 if (iFifoPos == FIFO_SIZE) |
48 iFifoPos = 0; |
67 iFifoPos = 0; |
49 |
68 |
50 return val; |
69 return val; |
51 } |
70 } |
52 |
71 |
53 void TPointerRv::FifoPush(struct TPointerRv::PData* val) |
72 void TPointerRv::FifoPush(struct TPointerRv::PData* val) |
54 { |
73 { |
55 TInt slot; |
74 TInt slot; |
56 |
75 |
57 if (iFifoCount == FIFO_SIZE) |
76 if (iFifoCount == FIFO_SIZE) |
58 return; |
77 return; |
59 |
78 |
60 slot = iFifoPos + iFifoCount; |
79 slot = iFifoPos + iFifoCount; |
61 if (slot >= FIFO_SIZE) |
80 if (slot >= FIFO_SIZE) |
62 slot -= FIFO_SIZE; |
81 slot -= FIFO_SIZE; |
63 iPDataFifo[slot] = *val; |
82 iPDataFifo[slot] = *val; |
64 iFifoCount++; |
83 iFifoCount++; |
72 { |
91 { |
73 __DEBUG_PRINT("TPointerRv::Init3"); |
92 __DEBUG_PRINT("TPointerRv::Init3"); |
74 |
93 |
75 TInt reg = ReadReg(KHwBaseKmiPointer,POINTER_ID); |
94 TInt reg = ReadReg(KHwBaseKmiPointer,POINTER_ID); |
76 WriteReg(KHwBaseKmiPointer,POINTER_INT_ENABLE,1); |
95 WriteReg(KHwBaseKmiPointer,POINTER_INT_ENABLE,1); |
77 |
96 |
78 TInt r = Kern::AddHalEntry(EHalGroupMouse,DoPointerHalFunction,this); |
97 TInt r = Kern::AddHalEntry(EHalGroupMouse,DoPointerHalFunction,this); |
79 if(r != KErrNone) |
98 if(r != KErrNone) |
80 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::Init3(): Kern::AddHalEntry()=%d", r)); |
99 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::Init3(): Kern::AddHalEntry()=%d", r)); |
81 |
100 |
82 // Get information about the screen display mode |
101 // Get information about the screen display mode |
84 TVideoInfoV01& videoInfo = buf(); |
103 TVideoInfoV01& videoInfo = buf(); |
85 |
104 |
86 r = Kern::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&buf, NULL); |
105 r = Kern::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, (TAny*)&buf, NULL); |
87 if(r != KErrNone) |
106 if(r != KErrNone) |
88 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::Init3(): Kern::HalFunction(EDisplayHalCurrentModeInfo)=%d", r)); |
107 __KTRACE_OPT(KPANIC, Kern::Printf("TPointerRv::Init3(): Kern::HalFunction(EDisplayHalCurrentModeInfo)=%d", r)); |
89 |
108 |
90 iScreenWidth = videoInfo.iSizeInPixels.iWidth; |
109 iScreenWidth = videoInfo.iSizeInPixels.iWidth; |
91 iScreenHeight = videoInfo.iSizeInPixels.iHeight; |
110 iScreenHeight = videoInfo.iSizeInPixels.iHeight; |
92 iDisplayMode = videoInfo.iDisplayMode; |
111 iDisplayMode = videoInfo.iDisplayMode; |
|
112 |
|
113 iVideoMem = videoInfo.iVideoAddress + videoInfo.iOffsetToFirstPixel; |
|
114 iOffSetBetweenEachLine = 640; |
|
115 |
93 ix = iy = 0; |
116 ix = iy = 0; |
94 |
117 |
95 iXFactor = Fixed(iScreenWidth) / Fixed(0x8000); |
118 iXFactor = Fixed(iScreenWidth) / Fixed(0x8000); |
96 iYFactor = Fixed(iScreenHeight) / Fixed(0x8000); |
119 iYFactor = Fixed(iScreenHeight) / Fixed(0x8000); |
97 |
120 |
98 iFifoPos = iFifoCount = 0; |
121 iFifoPos = iFifoCount = 0; |
|
122 |
|
123 |
|
124 iFirstTime= ETrue; |
|
125 |
99 } |
126 } |
100 |
127 |
101 |
128 |
102 void TPointerRv::Process(TPointerRv *i, struct TPointerRv::PData *pd) |
129 void TPointerRv::Process(TPointerRv *i, struct TPointerRv::PData *pd) |
103 { |
130 { |
106 // __DEBUG_PRINT("Event: X=%d Y=%d Point %d", pd->x, pd->y, pd->but); |
133 // __DEBUG_PRINT("Event: X=%d Y=%d Point %d", pd->x, pd->y, pd->but); |
107 // __DEBUG_PRINT(" Last X=%d Y=%d Point %d", i->ix, i->iy, i->iLastBut); |
134 // __DEBUG_PRINT(" Last X=%d Y=%d Point %d", i->ix, i->iy, i->iLastBut); |
108 |
135 |
109 // i->ix += pd->x; |
136 // i->ix += pd->x; |
110 // i->iy += pd->y; |
137 // i->iy += pd->y; |
111 |
138 |
112 i->ix = int(Fixed(pd->x) * i->iXFactor); |
139 i->ix = int(Fixed(pd->x) * i->iXFactor); |
113 i->iy = int(Fixed(pd->y) * i->iYFactor); |
140 i->iy = int(Fixed(pd->y) * i->iYFactor); |
114 |
141 |
115 switch(pd->but) |
142 switch(pd->but) |
116 { |
143 { |
153 } |
180 } |
154 break; |
181 break; |
155 |
182 |
156 } |
183 } |
157 fin: |
184 fin: |
|
185 |
|
186 |
|
187 // i->DisplayPointer(); |
|
188 |
|
189 |
158 Kern::AddEvent(e); |
190 Kern::AddEvent(e); |
159 i->iLastBut = pd->but; |
191 i->iLastBut = pd->but; |
160 } |
192 } |
161 |
193 |
|
194 |
|
195 void TPointerRv::DisplayPointer() |
|
196 { |
|
197 |
|
198 TUint32 *pMem =0; |
|
199 TInt k=0; |
|
200 |
|
201 if(!iFirstTime) |
|
202 { |
|
203 |
|
204 //restore old pointer position |
|
205 pMem = (TUint32 *)iVideoMem; |
|
206 |
|
207 pMem+= iYtop* iOffSetBetweenEachLine; |
|
208 pMem+= iXleft; |
|
209 |
|
210 |
|
211 |
|
212 for(TInt i=0;i<(iYbottom-iYtop);i++) |
|
213 { |
|
214 for(TInt j=0;j<(iXright-iXleft);j++) |
|
215 { |
|
216 *pMem = iImageStore[k]; |
|
217 pMem++; |
|
218 k++; |
|
219 |
|
220 } |
|
221 |
|
222 pMem+= (iOffSetBetweenEachLine - iXright) + iXleft; |
|
223 } |
|
224 } |
|
225 |
|
226 iFirstTime = EFalse; |
|
227 |
|
228 //10*10 pixel pointer centered around position and check are within allowed bounds of screen |
|
229 iXleft = ix - 5; |
|
230 |
|
231 if(iXleft<0) |
|
232 iXleft=0; |
|
233 |
|
234 iXright = ix + 5; |
|
235 |
|
236 if(iXright>iScreenWidth) |
|
237 iXright = iScreenWidth; |
|
238 |
|
239 iYtop = iy - 5; |
|
240 |
|
241 if(iYtop<0) |
|
242 iYtop=0; |
|
243 |
|
244 iYbottom = iy +5; |
|
245 |
|
246 if(iYbottom> iScreenHeight) |
|
247 iYbottom=iScreenHeight; |
|
248 |
|
249 pMem = (TUint32 *)iVideoMem; |
|
250 k=0; |
|
251 |
|
252 pMem+= iYtop* iOffSetBetweenEachLine; |
|
253 pMem+= iXleft; |
|
254 |
|
255 for(TInt i=0;i<(iYbottom-iYtop);i++) |
|
256 { |
|
257 for(TInt j=0;j<(iXright-iXleft);j++) |
|
258 { |
|
259 iImageStore[k] = *pMem; |
|
260 *pMem = 0; |
|
261 pMem++; |
|
262 k++; |
|
263 |
|
264 } |
|
265 |
|
266 pMem+= (iOffSetBetweenEachLine - iXright) + iXleft; |
|
267 } |
|
268 |
|
269 } |
|
270 |
|
271 |
162 void TPointerRv::RxDfc(TAny* aPtr) |
272 void TPointerRv::RxDfc(TAny* aPtr) |
163 { |
273 { |
164 __DEBUG_PRINT("TPointerRv::RxDfc"); |
274 __DEBUG_PRINT("TPointerRv::RxDfc"); |
165 |
275 |
166 TPointerRv* i = static_cast<TPointerRv*>(aPtr); |
276 TPointerRv* i = static_cast<TPointerRv*>(aPtr); |
167 |
277 |
168 while(i->iFifoCount>0) { |
278 while(i->iFifoCount>0) { |
169 struct TPointerRv::PData *pd= i->FifoPop(); |
279 struct TPointerRv::PData *pd= i->FifoPop(); |
170 Process(i,pd); |
280 Process(i,pd); |
171 } |
281 } |
176 __DEBUG_PRINT("TPointerRv::Isr"); |
286 __DEBUG_PRINT("TPointerRv::Isr"); |
177 |
287 |
178 TPointerRv& k = *(TPointerRv*)aPtr; |
288 TPointerRv& k = *(TPointerRv*)aPtr; |
179 // interrupts are now auto clear |
289 // interrupts are now auto clear |
180 |
290 |
181 while(ReadReg(KHwBaseKmiPointer, POINTER_FIFO_COUNT)!=0) { |
291 |
|
292 while(ReadReg(KHwBaseKmiPointer, POINTER_FIFO_COUNT)!=0) |
|
293 { |
|
294 |
|
295 WriteReg(KHwBaseKmiPointer,POINTER_LATCH,1); |
|
296 // SOSCO: moved to here, as the buffer seems to be running one notch out, |
|
297 // writing to the pointer latch first seems to return the correct FIFO entry. |
|
298 |
182 struct TPointerRv::PData pd; |
299 struct TPointerRv::PData pd; |
183 pd.x = ReadReg(KHwBaseKmiPointer,POINTER_X); |
300 pd.x = ReadReg(KHwBaseKmiPointer,POINTER_X); |
184 pd.y = ReadReg(KHwBaseKmiPointer,POINTER_Y); |
301 pd.y = ReadReg(KHwBaseKmiPointer,POINTER_Y); |
185 pd.z = ReadReg(KHwBaseKmiPointer,POINTER_Z); |
302 pd.z = ReadReg(KHwBaseKmiPointer,POINTER_Z); |
186 pd.but = ReadReg(KHwBaseKmiPointer,POINTER_BUTTONS); |
303 pd.but = ReadReg(KHwBaseKmiPointer,POINTER_BUTTONS); |
187 k.FifoPush(&pd); |
304 k.FifoPush(&pd); |
188 WriteReg(KHwBaseKmiPointer,POINTER_LATCH,0); |
305 |
|
306 // SOSCO - moved WriteReg(KHwBaseKmiPointer,POINTER_LATCH,1); |
|
307 |
189 } |
308 } |
190 |
309 |
191 // WriteReg(KHwBaseKmiPointer,POINTER_CLEAR_INT,0); |
310 // WriteReg(KHwBaseKmiPointer,POINTER_CLEAR_INT,0); |
192 Interrupt::Clear(EIntPointer); |
311 Interrupt::Clear(EIntPointer); |
193 k.iRxDfc.Add(); |
312 |
|
313 k.iRxDfc->Add(); |
|
314 |
194 } |
315 } |
195 |
316 |
196 TInt TPointerRv::DoPointerHalFunction(TAny* aThis, TInt aFunction, TAny* a1, TAny* a2) |
317 TInt TPointerRv::DoPointerHalFunction(TAny* aThis, TInt aFunction, TAny* a1, TAny* a2) |
197 { |
318 { |
198 return static_cast<TPointerRv*>(aThis)->PointerHalFunction(aFunction,a1,a2); |
319 return static_cast<TPointerRv*>(aThis)->PointerHalFunction(aFunction,a1,a2); |
208 { |
329 { |
209 case EMouseHalMouseState: |
330 case EMouseHalMouseState: |
210 { |
331 { |
211 kumemput32(a1, (TBool*)&iPointerOn, sizeof(TBool)); |
332 kumemput32(a1, (TBool*)&iPointerOn, sizeof(TBool)); |
212 break; |
333 break; |
213 } |
334 } |
214 case EMouseHalSetMouseState: |
335 case EMouseHalSetMouseState: |
215 { |
336 { |
|
337 |
|
338 /* SOSCO - removed, causes platsec error |
216 __SECURE_KERNEL( |
339 __SECURE_KERNEL( |
217 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
340 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
218 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseState"))) |
341 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseState"))) |
219 return KErrPermissionDenied; |
342 return KErrPermissionDenied; |
220 ); |
343 ); |
|
344 */ |
|
345 |
221 if(((TBool)a1 == HAL::EMouseState_Visible) && (iPointerOn == (TBool)EFalse)) |
346 if(((TBool)a1 == HAL::EMouseState_Visible) && (iPointerOn == (TBool)EFalse)) |
222 { |
347 { |
223 iPointerOn=(TBool)ETrue; |
348 iPointerOn=(TBool)ETrue; |
224 } |
349 } |
225 else if(((TBool)a1 == HAL::EMouseState_Invisible) && (iPointerOn==(TBool)ETrue)) |
350 else if(((TBool)a1 == HAL::EMouseState_Invisible) && (iPointerOn==(TBool)ETrue)) |
226 { |
351 { |
227 iPointerOn=(TBool)EFalse; |
352 iPointerOn=(TBool)EFalse; |
228 } |
353 } |
229 break; |
354 break; |
230 } |
355 } |
231 case EMouseHalMouseInfo: |
356 case EMouseHalMouseInfo: |
232 { |
357 { |
233 TPckgBuf<TMouseInfoV01> vPckg; |
358 TPckgBuf<TMouseInfoV01> vPckg; |
234 TMouseInfoV01& xyinfo = vPckg(); |
359 TMouseInfoV01& xyinfo = vPckg(); |
235 xyinfo.iMouseButtons = 2; |
360 xyinfo.iMouseButtons = 2; |
237 xyinfo.iMouseAreaSize.iHeight = iScreenHeight; |
362 xyinfo.iMouseAreaSize.iHeight = iScreenHeight; |
238 xyinfo.iOffsetToDisplay.iX = 0; |
363 xyinfo.iOffsetToDisplay.iX = 0; |
239 xyinfo.iOffsetToDisplay.iY = 0; |
364 xyinfo.iOffsetToDisplay.iY = 0; |
240 Kern::InfoCopy(*(TDes8*)a1,vPckg); |
365 Kern::InfoCopy(*(TDes8*)a1,vPckg); |
241 break; |
366 break; |
242 } |
367 } |
243 case EMouseHalSetMouseSpeed: |
368 case EMouseHalSetMouseSpeed: |
244 { |
369 { |
|
370 |
|
371 /* SOSCO - removed, causes platsec error |
245 __SECURE_KERNEL( |
372 __SECURE_KERNEL( |
246 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
373 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
247 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseSpeed"))) |
374 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseSpeed"))) |
248 return KErrPermissionDenied; |
375 return KErrPermissionDenied; |
249 ); |
376 ); |
|
377 */ |
|
378 |
250 // fall thru to NotSupported |
379 // fall thru to NotSupported |
251 } |
380 } |
252 case EMouseHalSetMouseAcceleration: |
381 case EMouseHalSetMouseAcceleration: |
253 { |
382 { |
|
383 |
|
384 /* SOSCO - removed, causes platsec error |
254 __SECURE_KERNEL( |
385 __SECURE_KERNEL( |
255 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
386 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD, |
256 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseAcceleration"))) |
387 __PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EMouseHalSetMouseAcceleration"))) |
257 return KErrPermissionDenied; |
388 return KErrPermissionDenied; |
258 ); |
389 ); |
|
390 */ |
|
391 |
259 // fall thru to NotSupported |
392 // fall thru to NotSupported |
260 } |
393 } |
261 default: |
394 default: |
262 { |
395 { |
263 r = KErrNotSupported; |
396 r = KErrNotSupported; |
264 break; |
397 break; |
265 } |
398 } |
266 } |
399 } |
267 return r; |
400 return r; |
268 } |
401 } |
269 |
402 |
270 DECLARE_STANDARD_EXTENSION() |
403 DECLARE_STANDARD_EXTENSION() |