Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pckbport Replace pms_synaptics_send_command() and id...
details: https://anonhg.NetBSD.org/src/rev/726b6a1fb4e0
branches: trunk
changeset: 769426:726b6a1fb4e0
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Fri Sep 09 14:29:47 2011 +0000
description:
Replace pms_synaptics_send_command() and identical pms_elantech_send_command()
with pms_sliced_command(). Linux shows that this sequence can also be used by
"Logitech PS/2++" protocol as well.
diffstat:
sys/dev/pckbport/elantech.c | 42 ++-------------------------------------
sys/dev/pckbport/pms.c | 31 ++++++++++++++++++++++++++--
sys/dev/pckbport/pmsvar.h | 4 ++-
sys/dev/pckbport/synaptics.c | 46 +++++--------------------------------------
4 files changed, 40 insertions(+), 83 deletions(-)
diffs (244 lines):
diff -r 26229b928c13 -r 726b6a1fb4e0 sys/dev/pckbport/elantech.c
--- a/sys/dev/pckbport/elantech.c Fri Sep 09 14:23:37 2011 +0000
+++ b/sys/dev/pckbport/elantech.c Fri Sep 09 14:29:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: elantech.c,v 1.3 2008/12/30 10:44:30 jmcneill Exp $ */
+/* $NetBSD: elantech.c,v 1.4 2011/09/09 14:29:47 jakllsch Exp $ */
/*-
* Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_pms.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elantech.c,v 1.3 2008/12/30 10:44:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elantech.c,v 1.4 2011/09/09 14:29:47 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -134,42 +134,6 @@
aprint_error("%s: sysctl_createv failed (rc = %d)\n", __func__, rc);
}
-/* lifted from synaptics.c */
-static int
-pms_elantech_send_command(pckbport_tag_t tag, pckbport_slot_t slot,
- uint8_t syn_cmd)
-{
- uint8_t cmd[2];
- int res;
-
- cmd[0] = PMS_SET_SCALE11;
- res = pckbport_poll_cmd(tag, slot, cmd, 1, 0, NULL, 0);
- if (res)
- return res;
-
- /*
- * Need to send 4 Set Resolution commands, with the argument
- * encoded in the bottom most 2 bits.
- */
- cmd[0] = PMS_SET_RES;
- cmd[1] = syn_cmd >> 6;
- res = pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x30) >> 4;
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x0c) >> 2;
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x03);
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- return res;
-}
-
static int
pms_elantech_read_1(pckbport_tag_t tag, pckbport_slot_t slot, uint8_t reg,
uint8_t *val)
@@ -383,7 +347,7 @@
goto doreset;
}
- res = pms_elantech_send_command(psc->sc_kbctag, psc->sc_kbcslot,
+ res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot,
ELANTECH_FW_VERSION);
cmd[0] = PMS_SEND_DEV_STATUS;
res |= pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot,
diff -r 26229b928c13 -r 726b6a1fb4e0 sys/dev/pckbport/pms.c
--- a/sys/dev/pckbport/pms.c Fri Sep 09 14:23:37 2011 +0000
+++ b/sys/dev/pckbport/pms.c Fri Sep 09 14:29:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pms.c,v 1.34 2011/09/08 16:34:09 jakllsch Exp $ */
+/* $NetBSD: pms.c,v 1.35 2011/09/09 14:29:47 jakllsch Exp $ */
/*-
* Copyright (c) 2004 Kentaro Kurahone.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.34 2011/09/08 16:34:09 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.35 2011/09/09 14:29:47 jakllsch Exp $");
#include "opt_pms.h"
@@ -224,7 +224,7 @@
/* no interrupts until enabled */
cmd[0] = PMS_DEV_DISABLE;
- res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, 0, 0);
+ res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, NULL, 0);
if (res)
aprint_error("pmsattach: disable error\n");
pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
@@ -653,3 +653,28 @@
return;
}
}
+
+int
+pms_sliced_command(pckbport_tag_t tag, pckbport_slot_t slot, u_char scmd)
+{
+ u_char cmd[2];
+ int i, err, ret = 0;
+
+ cmd[0] = PMS_SET_SCALE11;
+ ret = pckbport_poll_cmd(tag, slot, cmd, 1, 0, NULL, 0);
+
+ /*
+ * Need to send 4 Set Resolution commands, with the argument
+ * encoded in the bottom most 2 bits.
+ */
+ for (i = 6; i >= 0; i -= 2) {
+ cmd[0] = PMS_SET_RES;
+ cmd[1] = (scmd >> i) & 3;
+ err = pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
+ if (ret == 0 && err != 0) {
+ ret = err;
+ }
+ }
+
+ return ret;
+}
diff -r 26229b928c13 -r 726b6a1fb4e0 sys/dev/pckbport/pmsvar.h
--- a/sys/dev/pckbport/pmsvar.h Fri Sep 09 14:23:37 2011 +0000
+++ b/sys/dev/pckbport/pmsvar.h Fri Sep 09 14:29:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmsvar.h,v 1.10 2011/09/08 15:27:50 jakllsch Exp $ */
+/* $NetBSD: pmsvar.h,v 1.11 2011/09/09 14:29:47 jakllsch Exp $ */
/*-
* Copyright (c) 2004 Kentaro Kurahone.
@@ -74,4 +74,6 @@
#endif
};
+int pms_sliced_command(pckbport_tag_t, pckbport_slot_t, u_char);
+
#endif /* _DEV_PCKBCPORT_PMSVAR_H_ */
diff -r 26229b928c13 -r 726b6a1fb4e0 sys/dev/pckbport/synaptics.c
--- a/sys/dev/pckbport/synaptics.c Fri Sep 09 14:23:37 2011 +0000
+++ b/sys/dev/pckbport/synaptics.c Fri Sep 09 14:29:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: synaptics.c,v 1.26 2011/01/29 20:37:24 cegger Exp $ */
+/* $NetBSD: synaptics.c,v 1.27 2011/09/09 14:29:47 jakllsch Exp $ */
/*
* Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
#include "opt_pms.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.26 2011/01/29 20:37:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.27 2011/09/09 14:29:47 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -87,7 +87,6 @@
char sp_down; /* Down button status */
};
-static int pms_synaptics_send_command(pckbport_tag_t, pckbport_slot_t, u_char);
static void pms_synaptics_input(void *, int);
static void pms_synaptics_process_packet(struct pms_softc *,
struct synaptics_packet *);
@@ -141,7 +140,7 @@
int res, ver_minor, ver_major;
struct sysctllog *clog = NULL;
- res = pms_synaptics_send_command(psc->sc_kbctag, psc->sc_kbcslot,
+ res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot,
SYNAPTICS_IDENTIFY_TOUCHPAD);
cmd[0] = PMS_SEND_DEV_STATUS;
res |= pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 3,
@@ -180,7 +179,7 @@
}
/* Query the hardware capabilities. */
- res = pms_synaptics_send_command(psc->sc_kbctag, psc->sc_kbcslot,
+ res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot,
SYNAPTICS_READ_CAPABILITIES);
cmd[0] = PMS_SEND_DEV_STATUS;
res |= pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 3,
@@ -214,7 +213,7 @@
/* Ask about extra buttons to detect up/down. */
if (sc->caps & SYNAPTICS_CAP_EXTNUM) {
- res = pms_synaptics_send_command(psc->sc_kbctag,
+ res = pms_sliced_command(psc->sc_kbctag,
psc->sc_kbcslot, SYNAPTICS_EXTENDED_QUERY);
cmd[0] = PMS_SEND_DEV_STATUS;
res |= pckbport_poll_cmd(psc->sc_kbctag,
@@ -290,7 +289,7 @@
* Enable Absolute mode with W (width) reporting, and set
* the packet rate to maximum (80 packets per second).
*/
- res = pms_synaptics_send_command(psc->sc_kbctag, psc->sc_kbcslot,
+ res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot,
SYNAPTICS_MODE_ABSOLUTE | SYNAPTICS_MODE_W | SYNAPTICS_MODE_RATE);
cmd[0] = PMS_SET_SAMPLE;
cmd[1] = SYNAPTICS_CMD_SET_MODE2;
@@ -616,39 +615,6 @@
return (0);
}
-static int
-pms_synaptics_send_command(pckbport_tag_t tag, pckbport_slot_t slot,
- u_char syn_cmd)
-{
- u_char cmd[2];
- int res;
-
- cmd[0] = PMS_SET_SCALE11;
- res = pckbport_poll_cmd(tag, slot, cmd, 1, 0, NULL, 0);
-
- /*
- * Need to send 4 Set Resolution commands, with the argument
- * encoded in the bottom most 2 bits.
- */
- cmd[0] = PMS_SET_RES;
- cmd[1] = syn_cmd >> 6;
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x30) >> 4;
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x0c) >> 2;
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- cmd[0] = PMS_SET_RES;
- cmd[1] = (syn_cmd & 0x03);
- res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
-
- return (res);
-}
-
/* Masks for the first byte of a packet */
#define PMS_LBUTMASK 0x01
#define PMS_RBUTMASK 0x02
Home |
Main Index |
Thread Index |
Old Index