Skip to content

Commit

Permalink
psm(4): give names to synaptics commands
Browse files Browse the repository at this point in the history
Submitted by:	Ben LeMasurier <[email protected]>
MFC after:	2 weeks
  • Loading branch information
wulf7 committed Apr 20, 2019
1 parent b07da6e commit e56fffc
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions sys/dev/atkbdc/psm.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ typedef struct packetbuf {
#define PSM_PACKETQUEUE 128
#endif

/*
* Synaptics command definitions.
*/
#define SYNAPTICS_READ_IDENTITY 0x00
#define SYNAPTICS_READ_MODES 0x01
#define SYNAPTICS_READ_CAPABILITIES 0x02
#define SYNAPTICS_READ_MODEL_ID 0x03
#define SYNAPTICS_READ_SERIAL_PREFIX 0x06
#define SYNAPTICS_READ_SERIAL_SUFFIX 0x07
#define SYNAPTICS_READ_RESOLUTIONS 0x08
#define SYNAPTICS_READ_EXTENDED 0x09
#define SYNAPTICS_READ_CAPABILITIES_CONT 0x0c
#define SYNAPTICS_READ_MAX_COORDS 0x0d
#define SYNAPTICS_READ_DELUXE_LED 0x0e
#define SYNAPTICS_READ_MIN_COORDS 0x0f

typedef struct synapticsinfo {
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
Expand Down Expand Up @@ -1119,7 +1135,7 @@ doopen(struct psm_softc *sc, int command_byte)
"active multiplexing mode.\n",
sc->unit);
}
mouse_ext_command(sc->kbdc, 1);
mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODES);
get_mouse_status(sc->kbdc, stat, 0, 3);
if ((SYNAPTICS_VERSION_GE(sc->synhw, 7, 5) ||
stat[1] == 0x47) &&
Expand Down Expand Up @@ -6158,7 +6174,7 @@ synaptics_set_mode(struct psm_softc *sc, int mode_byte) {
*/
if ((sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) &&
sc->hw.model == MOUSE_MODEL_SYNAPTICS && !(mode_byte & (1 << 5))) {
mouse_ext_command(sc->kbdc, 3);
mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODEL_ID);
set_mouse_sampling_rate(sc->kbdc, 0xc8);
}
}
Expand Down Expand Up @@ -6238,7 +6254,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
set_mouse_scaling(kbdc, 1);

/* Identify the Touchpad version. */
if (mouse_ext_command(kbdc, 0) == 0)
if (mouse_ext_command(kbdc, SYNAPTICS_READ_IDENTITY) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand All @@ -6259,7 +6275,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
}

/* Get the Touchpad model information. */
if (mouse_ext_command(kbdc, 3) == 0)
if (mouse_ext_command(kbdc, SYNAPTICS_READ_MODEL_ID) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down Expand Up @@ -6290,7 +6306,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
}

/* Read the extended capability bits. */
if (mouse_ext_command(kbdc, 2) == 0)
if (mouse_ext_command(kbdc, SYNAPTICS_READ_CAPABILITIES) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down Expand Up @@ -6321,7 +6337,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)

if (!set_mouse_scaling(kbdc, 1))
return (FALSE);
if (mouse_ext_command(kbdc, 0x08) == 0)
if (mouse_ext_command(kbdc, SYNAPTICS_READ_RESOLUTIONS) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down Expand Up @@ -6358,7 +6374,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
if (synhw.nExtendedQueries >= 1) {
if (!set_mouse_scaling(kbdc, 1))
return (FALSE);
if (mouse_ext_command(kbdc, 0x09) == 0)
if (mouse_ext_command(kbdc,
SYNAPTICS_READ_EXTENDED) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down Expand Up @@ -6397,7 +6414,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
if (synhw.nExtendedQueries >= 4) {
if (!set_mouse_scaling(kbdc, 1))
return (FALSE);
if (mouse_ext_command(kbdc, 0x0c) == 0)
if (mouse_ext_command(kbdc,
SYNAPTICS_READ_CAPABILITIES_CONT) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand All @@ -6418,7 +6436,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
if (synhw.capReportsMax) {
if (!set_mouse_scaling(kbdc, 1))
return (FALSE);
if (mouse_ext_command(kbdc, 0x0d) == 0)
if (mouse_ext_command(kbdc,
SYNAPTICS_READ_MAX_COORDS) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand All @@ -6439,7 +6458,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
if (synhw.capReportsMin) {
if (!set_mouse_scaling(kbdc, 1))
return (FALSE);
if (mouse_ext_command(kbdc, 0x0f) == 0)
if (mouse_ext_command(kbdc,
SYNAPTICS_READ_MIN_COORDS) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down Expand Up @@ -6542,7 +6562,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
* byte of the response to this query to be a constant 0x3b, this
* does not appear to be true for Touchpads with guest devices.
*/
if (mouse_ext_command(kbdc, 1) == 0)
if (mouse_ext_command(kbdc, SYNAPTICS_READ_MODES) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
return (FALSE);
Expand Down

0 comments on commit e56fffc

Please sign in to comment.