Lines Matching refs:pb

385 #define	ELANTECH_FINGER_SET_XYP(pb) (finger_t) {			\  argument
386 .x = (((pb)->ipacket[1] & 0x0f) << 8) | (pb)->ipacket[2], \
387 .y = (((pb)->ipacket[4] & 0x0f) << 8) | (pb)->ipacket[5], \
388 .p = ((pb)->ipacket[1] & 0xf0) | (((pb)->ipacket[4] >> 4) & 0x0f), \
404 #define ELANTECH_PKT_IS_TRACKPOINT(pb) (((pb)->ipacket[3] & 0x0f) == 0x06) argument
405 #define ELANTECH_PKT_IS_DEBOUNCE(pb, hwversion) ((hwversion) == 4 ? 0 : \ argument
406 (pb)->ipacket[0] == ((hwversion) == 2 ? 0x84 : 0xc4) && \
407 (pb)->ipacket[1] == 0xff && (pb)->ipacket[2] == 0xff && \
408 (pb)->ipacket[3] == 0x02 && (pb)->ipacket[4] == 0xff && \
409 (pb)->ipacket[5] == 0xff)
410 #define ELANTECH_PKT_IS_V2(pb) \ argument
411 (((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0x0f) == 0x02)
412 #define ELANTECH_PKT_IS_V3_HEAD(pb, hascrc) ((hascrc) ? \ argument
413 ((pb)->ipacket[3] & 0x09) == 0x08 : \
414 ((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0xcf) == 0x02)
415 #define ELANTECH_PKT_IS_V3_TAIL(pb, hascrc) ((hascrc) ? \ argument
416 ((pb)->ipacket[3] & 0x09) == 0x09 : \
417 ((pb)->ipacket[0] & 0x0c) == 0x0c && ((pb)->ipacket[3] & 0xce) == 0x0c)
418 #define ELANTECH_PKT_IS_V4(pb, hascrc) ((hascrc) ? \ argument
419 ((pb)->ipacket[3] & 0x08) == 0x00 : \
420 ((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0x1c) == 0x10)
2374 tame_mouse(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *status, argument
2432 return (pb->inputbytes);
2998 packetbuf_t *pb; local
3006 pb = &sc->pqueue[sc->pqueue_end];
3013 if ((pb->inputbytes > 0) &&
3017 pb->inputbytes = 0;
3025 pb->ipacket[pb->inputbytes++] = c;
3028 VLOG(4, (LOG_DEBUG, "psmintr: %02x\n", pb->ipacket[0]));
3033 if (pb->inputbytes < sc->mode.packetsize)
3038 pb->ipacket[0], pb->ipacket[1], pb->ipacket[2],
3039 pb->ipacket[3], pb->ipacket[4], pb->ipacket[5]));
3042 c = pb->ipacket[0];
3089 pb->inputbytes = 0;
3096 pb->inputbytes--;
3097 bcopy(&pb->ipacket[1], &pb->ipacket[0],
3098 pb->inputbytes);
3118 pb->inputbytes = 0;
3156 proc_mmanplus(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms, argument
3187 if (((pb->ipacket[0] & MOUSE_PS2PLUS_SYNCMASK) == MOUSE_PS2PLUS_SYNC) &&
3188 (abs(*x) > 191) && MOUSE_PS2PLUS_CHECKBITS(pb->ipacket)) {
3193 switch (MOUSE_PS2PLUS_PACKET_TYPE(pb->ipacket)) {
3197 if (pb->ipacket[2] & 0x80) {
3202 *z = (pb->ipacket[2] & MOUSE_PS2PLUS_ZNEG) ?
3203 (pb->ipacket[2] & 0x0f) - 16 :
3204 (pb->ipacket[2] & 0x0f);
3206 ms->button |= (pb->ipacket[2] &
3209 ms->button |= (pb->ipacket[2] &
3225 if (pb->ipacket[2] & 0x0f)
3226 *z = (pb->ipacket[2] & MOUSE_SPOINT_WNEG) ?
3229 if (pb->ipacket[2] & 0xf0)
3230 *z = (pb->ipacket[2] & MOUSE_SPOINT_ZNEG) ?
3241 MOUSE_PS2PLUS_PACKET_TYPE(pb->ipacket),
3242 pb->ipacket[0], pb->ipacket[1], pb->ipacket[2]));
3252 proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms, argument
3312 if ((pb->ipacket[0] & 0xc8) != 0x80 ||
3313 (pb->ipacket[3] & 0xc8) != 0xc0)
3330 *z = pb->ipacket[2];
3345 w = ((pb->ipacket[0] & 0x30) >> 2) |
3346 ((pb->ipacket[0] & 0x04) >> 1) |
3347 ((pb->ipacket[3] & 0x04) >> 2);
3360 *x = ((pb->ipacket[1] & 0x10) ?
3361 pb->ipacket[4] - 256 : pb->ipacket[4]);
3362 *y = ((pb->ipacket[1] & 0x20) ?
3363 pb->ipacket[5] - 256 : pb->ipacket[5]);
3367 if (pb->ipacket[1] & 0x01)
3369 if (pb->ipacket[1] & 0x04)
3371 if (pb->ipacket[1] & 0x02)
3389 ewcode = (pb->ipacket[5] & 0xf0) >> 4;
3396 .x = (((pb->ipacket[4] & 0x0f) << 8) |
3397 pb->ipacket[1]) << 1,
3398 .y = (((pb->ipacket[4] & 0xf0) << 4) |
3399 pb->ipacket[2]) << 1,
3400 .p = ((pb->ipacket[3] & 0x30) |
3401 (pb->ipacket[5] & 0x0f)) << 1,
3407 .x = (((pb->ipacket[4] & 0x0f) << 8) |
3408 (pb->ipacket[1] & 0xfe)) << 1,
3409 .y = (((pb->ipacket[4] & 0xf0) << 4) |
3410 (pb->ipacket[2] & 0xfe)) << 1,
3411 .p = ((pb->ipacket[3] & 0x30) |
3412 (pb->ipacket[5] & 0x0e)) << 1,
3413 .w = (((pb->ipacket[5] & 0x01) << 2) |
3414 ((pb->ipacket[2] & 0x01) << 1) |
3415 (pb->ipacket[1] & 0x01)) + 8,
3420 ew_finger_count = pb->ipacket[1] & 0x0f;
3446 if (pb->ipacket[0] & 0x01)
3448 if (pb->ipacket[0] & 0x02)
3452 if ((pb->ipacket[3] ^ pb->ipacket[0]) & 0x01)
3454 if ((pb->ipacket[3] ^ pb->ipacket[0]) & 0x02)
3459 if ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x01)
3463 if ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x02) {
3465 if (pb->ipacket[4] & 0x01)
3467 if (pb->ipacket[5] & 0x01)
3469 if (pb->ipacket[4] & 0x02)
3471 if (pb->ipacket[5] & 0x02)
3474 if (pb->ipacket[4] & 0x01)
3476 if (pb->ipacket[5] & 0x01)
3478 if (pb->ipacket[4] & 0x02)
3511 pb->ipacket[4] & (1 << i));
3514 pb->ipacket[5] & (1 << i));
3518 pb->ipacket[4] &= ~(mask);
3519 pb->ipacket[5] &= ~(mask);
3532 .x = ((pb->ipacket[3] & 0x10) << 8) |
3533 ((pb->ipacket[1] & 0x0f) << 8) |
3534 (pb->ipacket[4] & 0xfd),
3535 .y = ((pb->ipacket[3] & 0x20) << 7) |
3536 ((pb->ipacket[1] & 0xf0) << 4) |
3537 (pb->ipacket[5] & 0xfd),
3539 .w = (((pb->ipacket[2] & 0x01) << 2) |
3540 (pb->ipacket[5] & 0x02) |
3541 ((pb->ipacket[4] & 0x02) >> 1)) + 8,
3546 .x = ((pb->ipacket[3] & 0x10) << 8) |
3547 ((pb->ipacket[1] & 0x0f) << 8) |
3548 pb->ipacket[4],
3549 .y = ((pb->ipacket[3] & 0x20) << 7) |
3550 ((pb->ipacket[1] & 0xf0) << 4) |
3551 pb->ipacket[5],
3563 clickpad_pressed = (pb->ipacket[0] ^ pb->ipacket[3]) & 0x01;
3668 proc_synaptics_mux(struct psm_softc *sc, packetbuf_t *pb) argument
3682 switch (pb->ipacket[0] & 0xc0) {
3684 bcopy(pb->ipacket, sc->muxsave, 3);
3693 bcopy(pb->ipacket, pb->ipacket + 3, 3);
3694 bcopy(sc->muxsave, pb->ipacket, 3);
3696 pb->ipacket[0] &= ~(0x08 | sc->muxmsbuttons);
3697 pb->ipacket[3] &= ~(0x08 | sc->muxmsbuttons);
3698 butt = (pb->ipacket[3] & 0x03) << 2 | (pb->ipacket[0] & 0x03);
3701 pb->ipacket[0] &= 0xfc;
3702 pb->ipacket[0] |= sc->muxtpbuttons & 0x03;
3703 pb->ipacket[3] &= 0xfc;
3704 pb->ipacket[3] |= sc->muxtpbuttons >> 2 & 0x03;
3712 (pb->ipacket[0] & 0x34) == 0x04 &&
3713 (pb->ipacket[3] & 0x04) == 0x04) {
3714 pb->ipacket[0] &= 0xfb;
3715 pb->ipacket[3] &= 0xfb;
3722 if (sc->muxmsbuttons & 0x03 || pb->ipacket[0] & 0x03 ||
3725 pb->ipacket[0] &= 0xfb;
3726 sc->muxmsbuttons = pb->ipacket[0] & 0x07;
3728 pb->ipacket[4] = pb->ipacket[1];
3729 pb->ipacket[5] = pb->ipacket[2];
3730 pb->ipacket[1] = pb->ipacket[0];
3731 pb->ipacket[2] = 0;
3732 pb->ipacket[0] = 0x84 | (sc->muxtpbuttons & 0x03);
3733 pb->ipacket[3] = 0xc4 | (sc->muxtpbuttons >> 2 & 0x03);
3737 pb->ipacket[0], pb->ipacket[1], pb->ipacket[2],
3738 pb->ipacket[3], pb->ipacket[4], pb->ipacket[5]));
3740 pb->inputbytes = MOUSE_SYNAPTICS_PACKETSIZE;
4377 proc_elantech(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms, argument
4388 if (ELANTECH_PKT_IS_DEBOUNCE(pb, sc->elanhw.hwversion))
4390 else if (sc->elanhw.hastrackpoint && ELANTECH_PKT_IS_TRACKPOINT(pb))
4395 if (!ELANTECH_PKT_IS_V2(pb))
4398 pkt = (pb->ipacket[0] & 0xc0) == 0x80 ?
4402 if (!ELANTECH_PKT_IS_V3_HEAD(pb, sc->elanhw.hascrc) &&
4403 !ELANTECH_PKT_IS_V3_TAIL(pb, sc->elanhw.hascrc))
4409 if (!ELANTECH_PKT_IS_V4(pb, sc->elanhw.hascrc))
4412 switch (pb->ipacket[3] & 0x03) {
4467 nfingers = (pb->ipacket[0] & 0xc0) >> 6;
4468 if (nfingers == 3 && (pb->ipacket[3] & 0x80))
4478 f[0] = ELANTECH_FINGER_SET_XYP(pb);
4480 f[0].w = ((pb->ipacket[0] & 0x30) >> 2) |
4481 ((pb->ipacket[3] & 0x30) >> 4);
4516 .x = (((pb->ipacket[id * 3] & 0x10) << 4) |
4517 pb->ipacket[id * 3 + 1]) << 2,
4518 .y = (((pb->ipacket[id * 3] & 0x20) << 3) |
4519 pb->ipacket[id * 3 + 2]) << 2,
4538 nfingers = (pb->ipacket[0] & 0xc0) >> 6;
4546 fn = ELANTECH_FINGER_SET_XYP(pb);
4547 fn.w = ((pb->ipacket[0] & 0x30) >> 2) |
4548 ((pb->ipacket[3] & 0x30) >> 4);
4558 if (ELANTECH_PKT_IS_V3_HEAD(pb, sc->elanhw.hascrc)) {
4583 mask = pb->ipacket[1] & 0x1f;
4618 id = ((pb->ipacket[3] & 0xe0) >> 5) - 1;
4619 fn = ELANTECH_FINGER_SET_XYP(pb);
4620 fn.w =(pb->ipacket[0] & 0xf0) >> 4;
4669 scale = (pb->ipacket[0] & 0x10) ? 5 : 1;
4671 id = ((pb->ipacket[i] & 0xe0) >> 5) - 1;
4678 (signed char)pb->ipacket[i+1] * scale);
4680 (signed char)pb->ipacket[i+2] * scale);
4703 if (!(pb->ipacket[0] & 0xC8) && !(pb->ipacket[1] & 0x7F) &&
4704 !(pb->ipacket[2] & 0x7F) && !(pb->ipacket[3] & 0xC9) &&
4705 !(pb->ipacket[0] & 0x10) != !(pb->ipacket[1] & 0x80) &&
4706 !(pb->ipacket[0] & 0x10) != !(pb->ipacket[3] & 0x10) &&
4707 !(pb->ipacket[0] & 0x20) != !(pb->ipacket[2] & 0x80) &&
4708 !(pb->ipacket[0] & 0x20) != !(pb->ipacket[3] & 0x20)) {
4709 *x = (pb->ipacket[0] & MOUSE_PS2_XNEG) ?
4710 pb->ipacket[4] - 256 : pb->ipacket[4];
4711 *y = (pb->ipacket[0] & MOUSE_PS2_YNEG) ?
4712 pb->ipacket[5] - 256 : pb->ipacket[5];
4715 ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) |
4716 ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0) |
4717 ((pb->ipacket[0] & 0x04) ? MOUSE_BUTTON2DOWN : 0);
4746 ((pb->ipacket[0] & 0x03) ? MOUSE_BUTTON1DOWN : 0);
4749 ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) |
4750 ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0);
4823 proc_versapad(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms, argument
4859 c = pb->ipacket[0];
4864 x0 = pb->ipacket[1] | (((pb->ipacket[4]) & 0x0f) << 8);
4865 y0 = pb->ipacket[2] | (((pb->ipacket[4]) & 0xf0) << 4);
4893 packetbuf_t *pb; local
4903 pb = &sc->pqueue[sc->pqueue_start];
4904 memcpy(pb, &sc->idlepacket, sizeof(packetbuf_t));
4907 pb->ipacket[0], pb->ipacket[1], pb->ipacket[2],
4908 pb->ipacket[3], pb->ipacket[4], pb->ipacket[5]));
4933 packetbuf_t *pb; local
4941 pb = &sc->pqueue[sc->pqueue_start];
4946 c = pb->ipacket[0];
4953 pb->ipacket[1] |= (c & MOUSE_PS2_XOVERFLOW) ? 0x80 : 0;
4957 pb->ipacket[1] - 256 : pb->ipacket[1];
4959 pb->ipacket[2] - 256 : pb->ipacket[2];
4983 z = (pb->ipacket[3] & MOUSE_EXPLORER_ZNEG) ?
4984 (pb->ipacket[3] & 0x0f) - 16 :
4985 (pb->ipacket[3] & 0x0f);
4987 (pb->ipacket[3] & MOUSE_EXPLORER_BUTTON4DOWN) ?
4990 (pb->ipacket[3] & MOUSE_EXPLORER_BUTTON5DOWN) ?
4997 z = (char)pb->ipacket[3];
5010 proc_mmanplus(sc, pb, &ms, &x, &y, &z);
5024 ms.button |= (pb->ipacket[3] & MOUSE_PS2_BUTTON3DOWN) ?
5026 ms.button |= (pb->ipacket[3] & MOUSE_PS2_BUTTON1DOWN) ?
5028 z = (pb->ipacket[3] & MOUSE_PS2_XNEG) ?
5029 pb->ipacket[4] - 256 : pb->ipacket[4];
5039 proc_versapad(sc, pb, &ms, &x, &y, &z);
5056 x = (pb->ipacket[1] & 0x80) ?
5057 pb->ipacket[1] - 256 : pb->ipacket[1];
5058 y = (pb->ipacket[2] & 0x80) ?
5059 pb->ipacket[2] - 256 : pb->ipacket[2];
5090 if (pb->ipacket[2] & MOUSE_4DPLUS_BUTTON4DOWN)
5092 z = (pb->ipacket[2] & MOUSE_4DPLUS_ZNEG) ?
5093 ((pb->ipacket[2] & 0x07) - 8) :
5094 (pb->ipacket[2] & 0x07) ;
5102 if (pb->inputbytes == MOUSE_PS2_PACKETSIZE)
5103 if (proc_synaptics_mux(sc, pb))
5106 if (proc_synaptics(sc, pb, &ms, &x, &y, &z) != 0) {
5114 if (proc_elantech(sc, pb, &ms, &x, &y, &z) != 0) {
5129 sc->idlepacket = *pb;
5194 pb->inputbytes = tame_mouse(sc, pb, &ms, pb->ipacket);
5207 if (sc->queue.count + pb->inputbytes < sizeof(sc->queue.buf)) {
5208 l = imin(pb->inputbytes,
5210 bcopy(&pb->ipacket[0], &sc->queue.buf[sc->queue.tail], l);
5211 if (pb->inputbytes > l)
5212 bcopy(&pb->ipacket[l], &sc->queue.buf[0],
5213 pb->inputbytes - l);
5214 sc->queue.tail = (sc->queue.tail + pb->inputbytes) %
5216 sc->queue.count += pb->inputbytes;
5220 pb->inputbytes = 0;