On Wed, 1 Apr 2015 18:02:59 +0200
Stefan Sperling <[email protected]> wrote:
> Interesting, thanks.
>
> If you don't hear from anyone else about this please ask me again in
> a week from now. I can test on v3 hardware by then but not any earlier.
>
> Please write this as if-else instead of switch:
>
> > @@ -2271,11 +2284,18 @@ pms_proc_elantech_v3(struct pms_softc *s
> > * and a tail packet. We report a single event and ignore
> > * the tail packet.
> > */
> > - if ((sc->packet[0] & 0x0c) != 0x04 &&
> > - (sc->packet[3] & 0xcf) != 0x02) {
> > - /* not the head packet -- ignore */
> > - return;
> > + switch (elantech->flags & ELANTECH_F_CRC_ENABLED) {
> > + case 0:
> > + if ((sc->packet[0] & 0x0c) != 0x04 &&
> > + (sc->packet[3] & 0xcf) != 0x02) {
> > + /* not the head packet -- ignore */
> > + return;
> > + }
> > + case ELANTECH_F_CRC_ENABLED:
> > + if ((sc->packet[3] & 0x09) != 0x08)
> > + return;
> > }
Thanks for the offer I will propably take you up on that.
Below is the modified diff with the switch statement transformed.
Index: sys/dev/pckbc/pms.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.58
diff -u -p -r1.58 pms.c
--- sys/dev/pckbc/pms.c 26 Mar 2015 01:30:22 -0000 1.58
+++ sys/dev/pckbc/pms.c 1 Apr 2015 16:31:33 -0000
@@ -137,6 +137,7 @@ struct elantech_softc {
#define ELANTECH_F_HAS_ROCKER 0x02
#define ELANTECH_F_2FINGER_PACKET 0x04
#define ELANTECH_F_HW_V1_OLD 0x08
+#define ELANTECH_F_CRC_ENABLED 0x10
int fw_version;
int min_x, min_y;
@@ -1812,6 +1813,9 @@ elantech_get_hwinfo_v3(struct pms_softc
elantech->fw_version = fw_version;
elantech->flags |= ELANTECH_F_REPORTS_PRESSURE;
+ if ((fw_version & 0x4000) == 0x4000)
+ elantech->flags |= ELANTECH_F_CRC_ENABLED;
+
if (elantech_set_absolute_mode_v3(sc))
return (-1);
@@ -2164,14 +2168,23 @@ pms_sync_elantech_v2(struct pms_softc *s
int
pms_sync_elantech_v3(struct pms_softc *sc, int data)
{
+ struct elantech_softc *elantech = sc->elantech;
+
switch (sc->inputstate) {
case 0:
+ if (elantech->flags & ELANTECH_F_CRC_ENABLED)
+ break;
if ((data & 0x0c) != 0x04 && (data & 0x0c) != 0x0c)
return (-1);
break;
case 3:
- if ((data & 0xcf) != 0x02 && (data & 0xce) != 0x0c)
- return (-1);
+ if (elantech->flags & ELANTECH_F_CRC_ENABLED) {
+ if ((data & 0x09) != 0x08 && (data & 0x09) != 0x09)
+ return (-1);
+ } else {
+ if ((data & 0xcf) != 0x02 && (data & 0xce) != 0x0c)
+ return (-1);
+ }
break;
}
@@ -2271,10 +2284,15 @@ pms_proc_elantech_v3(struct pms_softc *s
* and a tail packet. We report a single event and ignore
* the tail packet.
*/
- if ((sc->packet[0] & 0x0c) != 0x04 &&
- (sc->packet[3] & 0xcf) != 0x02) {
- /* not the head packet -- ignore */
- return;
+ if (elantech->flags & ELANTECH_F_CRC_ENABLED) {
+ if ((sc->packet[3] & 0x09) != 0x08)
+ return;
+ } else {
+ if ((sc->packet[0] & 0x0c) != 0x04 &&
+ (sc->packet[3] & 0xcf) != 0x02) {
+ /* not the head packet -- ignore */
+ return;
+ }
}
}