Commit 2fa1308110639d89c63a197efb53bd3b3791a51f

  • avatar
  • Peter Hutterer <peter.hutterer @wh…t.net> (Committer)
  • Wed Dec 23 00:11:13 CET 2009
  • avatar
  • Przemo Firszt (Author)
  • Tue Dec 22 20:49:54 CET 2009
Rename xf86Wcm* to wcm*

Rename xf86WcmFilterCoord to WcmFilterCoord

Rename xf86WcmSetPressureCurve to wcmSetPressureCurve

Rename xf86WcmFilterIntuos to wcmFilterIntuos

Rename xf86WcmSerialValidate to wcmSerialValidate

Rename xf86WcmWaitForTablet to wcmWaitForTablet

Rename xf86WcmWriteWait to wcmWriteWait

Rename xf86WcmWait to wcmWait

Rename xf86WcmReadPacket to wcmReadPacket

Rename xf86WcmEvent* to wcmEvent*

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  
10881088}
10891089
10901090/*****************************************************************************
1091 * xf86WcmEvent -
1091 * wcmEvent -
10921092 * Handles suppression, transformation, filtering, and event dispatch.
10931093 ****************************************************************************/
10941094
1095void xf86WcmEvent(WacomCommonPtr common, unsigned int channel,
1095void wcmEvent(WacomCommonPtr common, unsigned int channel,
10961096 const WacomDeviceState* pState)
10971097{
10981098 WacomDeviceState* pLast;
11041104 pChannel = common->wcmChannel + channel;
11051105 pLast = &pChannel->valid.state;
11061106
1107 DBG(10, common->debugLevel, xf86Msg(X_INFO, "xf86WcmEvent at channel = %d\n", channel));
1107 DBG(10, common->debugLevel, xf86Msg(X_INFO, "wcmEvent at channel = %d\n", channel));
11081108
11091109 /* sanity check the channel */
11101110 if (channel >= MAX_CHANNELS)
11161116
11171117 /* timestamp the state for velocity and acceleration analysis */
11181118 ds.sample = (int)GetTimeInMillis();
1119 DBG(10, common->debugLevel, xf86Msg(X_INFO, "xf86WcmEvent: "
1119 DBG(10, common->debugLevel, xf86Msg(X_INFO, "wcmEvent: "
11201120 "c=%d i=%d t=%d s=%u x=%d y=%d b=%d "
11211121 "p=%d rz=%d tx=%d ty=%d aw=%d rw=%d "
11221122 "t=%d df=%d px=%d st=%d cs=%d \n",
14231423 * access errors to the device */
14241424 if (pDev && !miPointerGetScreen(pDev->dev))
14251425 {
1426 xf86Msg(X_ERROR, "xf86WcmEvent: Wacom driver can not get Current Screen ID\n");
1426 xf86Msg(X_ERROR, "wcmEvent: Wacom driver can not get Current Screen ID\n");
14271427 xf86Msg(X_ERROR, "Please remove Wacom tool from the tablet and bring it back again.\n");
14281428 return;
14291429 }
  
3636static void filterIntuosStylus(WacomCommonPtr common, WacomFilterStatePtr state, WacomDeviceStatePtr ds);
3737
3838/*****************************************************************************
39 * xf86WcmSetPressureCurve -- apply user-defined curve to pressure values
39 * wcmSetPressureCurve -- apply user-defined curve to pressure values
4040 ****************************************************************************/
4141
42void xf86WcmSetPressureCurve(WacomDevicePtr pDev, int x0, int y0,
42void wcmSetPressureCurve(WacomDevicePtr pDev, int x0, int y0,
4343 int x1, int y1)
4444{
4545 int i;
5555 (FILTER_PRESSURE_RES + 1));
5656 if (!pDev->pPressCurve)
5757 {
58 xf86Msg(X_ERROR, "%s: xf86WcmSetPressureCurve: failed to "
58 xf86Msg(X_ERROR, "%s: wcmSetPressureCurve: failed to "
5959 "allocate memory for curve\n", pDev->local->name);
6060 return;
6161 }
236236}
237237
238238/*****************************************************************************
239 * xf86WcmFilterCoord -- provide noise correction to all transducers
239 * wcmFilterCoord -- provide noise correction to all transducers
240240 ****************************************************************************/
241241
242int xf86WcmFilterCoord(WacomCommonPtr common, WacomChannelPtr pChannel,
242int wcmFilterCoord(WacomCommonPtr common, WacomChannelPtr pChannel,
243243 WacomDeviceStatePtr ds)
244244{
245245 /* Only noise correction should happen here. If there's a problem that
248248 WacomDeviceState *pLast;
249249 int *x, *y, i;
250250
251 DBG(10, common->debugLevel, xf86Msg(X_INFO, "xf86WcmFilterCoord with "
251 DBG(10, common->debugLevel, xf86Msg(X_INFO, "wcmFilterCoord with "
252252 "common->wcmRawSample = %d \n", common->wcmRawSample));
253253 x = pChannel->rawFilter.x;
254254 y = pChannel->rawFilter.y;
269269}
270270
271271/*****************************************************************************
272 * xf86WcmFilterIntuos -- provide error correction to Intuos and Intuos2
272 * wcmFilterIntuos -- provide error correction to Intuos and Intuos2
273273 ****************************************************************************/
274274
275int xf86WcmFilterIntuos(WacomCommonPtr common, WacomChannelPtr pChannel,
275int wcmFilterIntuos(WacomCommonPtr common, WacomChannelPtr pChannel,
276276 WacomDeviceStatePtr ds)
277277{
278278 /* Only error correction should happen here. If there's a problem that
281281 if (ds->device_type != CURSOR_ID)
282282 filterIntuosStylus(common, &pChannel->rawFilter, ds);
283283 else
284 xf86WcmFilterCoord(common, pChannel, ds);
284 wcmFilterCoord(common, pChannel, ds);
285285
286286 return 0; /* lookin' good */
287287}
  
2424
2525/****************************************************************************/
2626
27void xf86WcmSetPressureCurve(WacomDevicePtr pDev, int x0, int y0,
27void wcmSetPressureCurve(WacomDevicePtr pDev, int x0, int y0,
2828 int x1, int y1);
29int xf86WcmFilterIntuos(WacomCommonPtr common, WacomChannelPtr pChannel,
29int wcmFilterIntuos(WacomCommonPtr common, WacomChannelPtr pChannel,
3030 WacomDeviceStatePtr ds);
31int xf86WcmFilterCoord(WacomCommonPtr common, WacomChannelPtr pChannel,
31int wcmFilterCoord(WacomCommonPtr common, WacomChannelPtr pChannel,
3232 WacomDeviceStatePtr ds);
3333
3434/****************************************************************************/
  
3535static int isdv4GetRanges(LocalDevicePtr);
3636static int isdv4StartTablet(LocalDevicePtr);
3737static int isdv4Parse(LocalDevicePtr, const unsigned char* data);
38static int xf86WcmSerialValidate(WacomCommonPtr common, const unsigned char* data);
39static int xf86WcmWaitForTablet(int fd, char * data, int size);
40static int xf86WcmWriteWait(int fd, const char* request);
38static int wcmSerialValidate(WacomCommonPtr common, const unsigned char* data);
39static int wcmWaitForTablet(int fd, char * data, int size);
40static int wcmWriteWait(int fd, const char* request);
4141
4242
4343 WacomDeviceClass gWacomISDV4Device =
4444 {
4545 isdv4Detect,
4646 isdv4Init,
47 xf86WcmReadPacket,
47 wcmReadPacket,
4848 };
4949
5050 static WacomModel isdv4General =
6565 * XFree86 V4 Functions
6666 ****************************************************************************/
6767
68static int xf86WcmWait(int t)
68static int wcmWait(int t)
6969{
7070 int err = xf86WaitForInput(-1, ((t) * 1000));
7171 if (err != -1)
7676}
7777
7878/*****************************************************************************
79 * xf86WcmSerialValidate -- validates serial packet; returns 0 on success,
79 * wcmSerialValidate -- validates serial packet; returns 0 on success,
8080 * positive number of bytes to skip on error.
8181 ****************************************************************************/
8282
83static int xf86WcmSerialValidate(WacomCommonPtr common, const unsigned char* data)
83static int wcmSerialValidate(WacomCommonPtr common, const unsigned char* data)
8484{
8585 int i, bad = 0;
8686
9292 {
9393 bad = 1;
9494 if (i!=0 && (data[i] & HEADER_BIT)) {
95 xf86Msg(X_WARNING, "xf86WcmSerialValidate: "
95 xf86Msg(X_WARNING, "wcmSerialValidate: "
9696 "bad magic at %d v=%x l=%d\n", i,
9797 data[i], common->wcmPktLength);
9898 return i;
162162 }
163163
164164 /* Wait 250 mSecs */
165 if (xf86WcmWait(250))
165 if (wcmWait(250))
166166 return !Success;
167167
168168 /* Send query command to the tablet */
169 if (!xf86WcmWriteWait(local->fd, query))
169 if (!wcmWriteWait(local->fd, query))
170170 {
171171 xf86Msg(X_WARNING, "%s: unable to xf86WcmWrite request %s "
172172 "ISDV4 query command after %d tries\n", local->name,
175175 }
176176
177177 /* Read the control data */
178 if (!xf86WcmWaitForTablet(local->fd, data, WACOM_PKGLEN_TPCCTL))
178 if (!wcmWaitForTablet(local->fd, data, WACOM_PKGLEN_TPCCTL))
179179 {
180180 /* Try 19200 if it is not a touch query */
181181 if (common->wcmISDV4Speed != 19200 && strcmp(query, WC_ISDV4_TOUCH_QUERY))
208208 else
209209 {
210210 /* Reread the control data since it may fail the first time */
211 xf86WcmWaitForTablet(local->fd, data, WACOM_PKGLEN_TPCCTL);
211 wcmWaitForTablet(local->fd, data, WACOM_PKGLEN_TPCCTL);
212212 if ( !(data[0] & 0x40) )
213213 {
214214 xf86Msg(X_WARNING, "%s: ISDV4 control data "
421421 /* let touch go */
422422 WacomDeviceState out = { 0 };
423423 out.device_type = TOUCH_ID;
424 xf86WcmEvent(common, channel, &out);
424 wcmEvent(common, channel, &out);
425425 }
426426 }
427427
434434 /* Coordinate data bit check */
435435 if (data[0] & 0x40) /* control data */
436436 return common->wcmPktLength;
437 else if ((n = xf86WcmSerialValidate(common,data)) > 0)
437 else if ((n = wcmSerialValidate(common,data)) > 0)
438438 return n;
439439
440440 /* pick up where we left off, minus relative values */
466466 if ((ds->proximity && !last->proximity) ||
467467 (!ds->proximity && last->proximity))
468468 ds->sample = (int)GetTimeInMillis();
469 xf86WcmEvent(common, channel, ds);
469 wcmEvent(common, channel, ds);
470470 }
471471
472472 channel = 1;
519519 {
520520 /* send a prox-out for old device */
521521 WacomDeviceState out = { 0 };
522 xf86WcmEvent(common, 0, &out);
522 wcmEvent(common, 0, &out);
523523 ds->device_type = cur_type;
524524 }
525525 }
540540 ds->device_type == ERASER_ID ? "ERASER " :
541541 ds->device_type == STYLUS_ID ? "STYLUS" : "NONE"));
542542 }
543 xf86WcmEvent(common, channel, ds);
543 wcmEvent(common, channel, ds);
544544 return common->wcmPktLength;
545545}
546546
549549 * send a request
550550 ****************************************************************************/
551551
552static int xf86WcmWriteWait(int fd, const char* request)
552static int wcmWriteWait(int fd, const char* request)
553553{
554554 int len, maxtry = MAXTRY;
555555
559559 len = xf86WriteSerial(fd, request, strlen(request));
560560 if ((len == -1) && (errno != EAGAIN))
561561 {
562 xf86Msg(X_ERROR, "Wacom xf86WcmWriteWait error : %s", strerror(errno));
562 xf86Msg(X_ERROR, "Wacom wcmWriteWait error : %s", strerror(errno));
563563 return 0;
564564 }
565565
571571}
572572
573573/*****************************************************************************
574 * xf86WcmWaitForTablet --
574 * wcmWaitForTablet --
575575 * wait for tablet data
576576 ****************************************************************************/
577577
578static int xf86WcmWaitForTablet(int fd, char* answer, int size)
578static int wcmWaitForTablet(int fd, char* answer, int size)
579579{
580580 int len, maxtry = MAXTRY;
581581
src/wcmUSB.c
(18 / 18)
  
5353 {
5454 usbDetect,
5555 usbWcmInit,
56 xf86WcmReadPacket,
56 wcmReadPacket,
5757 };
5858
5959 static WacomModel usbUnknown =
8484 NULL, /* link speed unsupported */
8585 NULL, /* start not supported */
8686 usbParse,
87 xf86WcmFilterCoord, /* input filtering */
87 wcmFilterCoord, /* input filtering */
8888 usbDetectConfig, /* detect hardware buttons etc */
8989 };
9090
100100 NULL, /* link speed unsupported */
101101 NULL, /* start not supported */
102102 usbParse,
103 xf86WcmFilterCoord, /* input filtering */
103 wcmFilterCoord, /* input filtering */
104104 usbDetectConfig, /* detect hardware buttons etc */
105105 };
106106
116116 NULL, /* link speed unsupported */
117117 NULL, /* start not supported */
118118 usbParse,
119 xf86WcmFilterCoord, /* input filtering */
119 wcmFilterCoord, /* input filtering */
120120 usbDetectConfig, /* detect hardware buttons etc */
121121 };
122122
132132 NULL, /* link speed unsupported */
133133 NULL, /* start not supported */
134134 usbParse,
135 xf86WcmFilterCoord, /* input filtering */
135 wcmFilterCoord, /* input filtering */
136136 usbDetectConfig, /* detect hardware buttons etc */
137137 };
138138
148148 NULL, /* link speed unsupported */
149149 NULL, /* start not supported */
150150 usbParse,
151 xf86WcmFilterCoord, /* input filtering */
151 wcmFilterCoord, /* input filtering */
152152 usbDetectConfig, /* detect hardware buttons etc */
153153 };
154154
164164 NULL, /* link speed unsupported */
165165 NULL, /* start not supported */
166166 usbParse,
167 xf86WcmFilterCoord, /* input filtering */
167 wcmFilterCoord, /* input filtering */
168168 usbDetectConfig, /* detect hardware buttons etc */
169169 };
170170
180180 NULL, /* link speed unsupported */
181181 NULL, /* start not supported */
182182 usbParse,
183 xf86WcmFilterCoord, /* input filtering */
183 wcmFilterCoord, /* input filtering */
184184 usbDetectConfig, /* detect hardware buttons etc */
185185 };
186186
196196 NULL, /* link speed unsupported */
197197 NULL, /* start not supported */
198198 usbParse,
199 xf86WcmFilterCoord, /* input filtering */
199 wcmFilterCoord, /* input filtering */
200200 usbDetectConfig, /* detect hardware buttons etc */
201201 };
202202
244244 NULL, /* link speed unsupported */
245245 NULL, /* start not supported */
246246 usbParse,
247 xf86WcmFilterIntuos, /* input filtering recommended */
247 wcmFilterIntuos, /* input filtering recommended */
248248 usbDetectConfig, /* detect hardware buttons etc */
249249 };
250250
260260 NULL, /* link speed unsupported */
261261 NULL, /* start not supported */
262262 usbParse,
263 xf86WcmFilterIntuos, /* input filtering recommended */
263 wcmFilterIntuos, /* input filtering recommended */
264264 usbDetectConfig, /* detect hardware buttons etc */
265265 };
266266
276276 NULL, /* link speed unsupported */
277277 NULL, /* start not supported */
278278 usbParse,
279 xf86WcmFilterIntuos, /* input filtering recommended */
279 wcmFilterIntuos, /* input filtering recommended */
280280 usbDetectConfig, /* detect hardware buttons etc */
281281 };
282282
292292 NULL, /* link speed unsupported */
293293 NULL, /* start not supported */
294294 usbParse,
295 xf86WcmFilterIntuos, /* input filtering recommended */
295 wcmFilterIntuos, /* input filtering recommended */
296296 usbDetectConfig, /* detect hardware buttons etc */
297297 };
298298
308308 NULL, /* link speed unsupported */
309309 NULL, /* start not supported */
310310 usbParse,
311 xf86WcmFilterCoord, /* input filtering */
311 wcmFilterCoord, /* input filtering */
312312 usbDetectConfig, /* detect hardware buttons etc */
313313 };
314314
324324 NULL, /* link speed unsupported */
325325 NULL, /* start not supported */
326326 usbParse,
327 xf86WcmFilterCoord, /* input filtering */
327 wcmFilterCoord, /* input filtering */
328328 usbDetectConfig, /* detect hardware buttons etc */
329329 };
330330
340340 NULL, /* link speed unsupported */
341341 NULL, /* start not supported */
342342 usbParse,
343 xf86WcmFilterIntuos, /* input filtering recommended */
343 wcmFilterIntuos, /* input filtering recommended */
344344 usbDetectConfig, /* detect hardware buttons etc */
345345 };
346346
810810 {
811811 common->wcmChannel[i].work.proximity = 0;
812812 /* dispatch event */
813 xf86WcmEvent(common, i, &common->wcmChannel[i].work);
813 wcmEvent(common, i, &common->wcmChannel[i].work);
814814 }
815815 }
816816 DBG(1, common->debugLevel, xf86Msg(X_INFO, "usbParse (device with serial number: %u)"
11211121 }
11221122
11231123 /* dispatch event */
1124 xf86WcmEvent(common, channel, ds);
1124 wcmEvent(common, channel, ds);
11251125}
11261126/* vim: set noexpandtab shiftwidth=8: */
  
495495 local->name);
496496 else
497497 {
498 xf86WcmSetPressureCurve(priv,a,b,c,d);
498 wcmSetPressureCurve(priv,a,b,c,d);
499499 }
500500 }
501501
714714 if ((!common->wcmDevice || !strcmp (common->wcmDevice, "auto-dev")))
715715 {
716716 common->wcmFlags |= AUTODEV_FLAG;
717 if (! (common->wcmDevice = xf86WcmEventAutoDevProbe (local)))
717 if (! (common->wcmDevice = wcmEventAutoDevProbe (local)))
718718 {
719719 xf86Msg(X_ERROR, "%s: unable to probe device\n",
720720 local->name);
  
372372 return BadValue;
373373
374374 if (!checkonly)
375 xf86WcmSetPressureCurve (priv, pcurve[0], pcurve[1],
375 wcmSetPressureCurve (priv, pcurve[0], pcurve[1],
376376 pcurve[2], pcurve[3]);
377377 } else if (property == prop_suppress)
378378 {
  
924924}
925925
926926/*****************************************************************************
927 * xf86WcmEventAutoDevProbe -- Probe for right input device
927 * wcmEventAutoDevProbe -- Probe for right input device
928928 ****************************************************************************/
929929#define DEV_INPUT_EVENT "/dev/input/event%d"
930930#define EVDEV_MINORS 32
931char *xf86WcmEventAutoDevProbe (LocalDevicePtr local)
931char *wcmEventAutoDevProbe (LocalDevicePtr local)
932932{
933933 /* We are trying to find the right eventX device */
934934 int i, wait = 0;
10461046 {
10471047 /* Autoprobe if necessary */
10481048 if ((common->wcmFlags & AUTODEV_FLAG) &&
1049 !(common->wcmDevice = xf86WcmEventAutoDevProbe (local)))
1049 !(common->wcmDevice = wcmEventAutoDevProbe (local)))
10501050 xf86Msg(X_ERROR, "%s: Cannot probe device\n", local->name);
10511051
10521052 if ((xf86WcmOpen (local) != Success) || (local->fd < 0) ||
11351135 DBG(10, priv->debugLevel, xf86Msg(X_INFO, "xf86WcmDevReadInput: Read (%d)\n",loop));
11361136}
11371137
1138void xf86WcmReadPacket(LocalDevicePtr local)
1138void wcmReadPacket(LocalDevicePtr local)
11391139{
11401140 WacomDevicePtr priv = (WacomDevicePtr)local->private;
11411141 WacomCommonPtr common = priv->common;
11421142 int len, pos, cnt, remaining;
11431143 unsigned char * data;
11441144
1145 DBG(10, common->debugLevel, xf86Msg(X_INFO, "xf86WcmReadPacket: device=%s"
1145 DBG(10, common->debugLevel, xf86Msg(X_INFO, "wcmReadPacket: device=%s"
11461146 " fd=%d \n", common->wcmDevice, local->fd));
11471147
11481148 remaining = sizeof(common->buffer) - common->bufpos;
11491149
1150 DBG(1, common->debugLevel, xf86Msg(X_INFO, "xf86WcmReadPacket: pos=%d"
1150 DBG(1, common->debugLevel, xf86Msg(X_INFO, "wcmReadPacket: pos=%d"
11511151 " remaining=%d\n", common->bufpos, remaining));
11521152
11531153 /* fill buffer with as much data as we can handle */
11711171
11721172 /* account for new data */
11731173 common->bufpos += len;
1174 DBG(10, common->debugLevel, xf86Msg(X_INFO, "xf86WcmReadPacket buffer has %d bytes\n",
1174 DBG(10, common->debugLevel, xf86Msg(X_INFO, "wcmReadPacket buffer has %d bytes\n",
11751175 common->bufpos));
11761176
11771177 pos = 0;
  
146146#define RESET_RELATIVE(ds) do { (ds).relwheel = 0; } while (0)
147147
148148/* device autoprobing */
149char *xf86WcmEventAutoDevProbe (LocalDevicePtr local);
149char *wcmEventAutoDevProbe (LocalDevicePtr local);
150150
151151/* common tablet initialization regime */
152152int xf86WcmInitTablet(LocalDevicePtr local, const char* id, float version);
153153
154154/* standard packet handler */
155void xf86WcmReadPacket(LocalDevicePtr local);
155void wcmReadPacket(LocalDevicePtr local);
156156
157157/* handles suppression, filtering, and dispatch. */
158void xf86WcmEvent(WacomCommonPtr common, unsigned int channel, const WacomDeviceState* ds);
158void wcmEvent(WacomCommonPtr common, unsigned int channel, const WacomDeviceState* ds);
159159
160160/* dispatches data to XInput event system */
161161void xf86WcmSendEvents(LocalDevicePtr local, const WacomDeviceState* ds);