Deleted Added
full compact
psm.c (282734) psm.c (284320)
1/*-
2 * Copyright (c) 1992, 1993 Erik Forsberg.
3 * Copyright (c) 1996, 1997 Kazutaka YOKOTA.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 45 unchanged lines hidden (view full) ---

54 * HiNote UltraII/Latitude/Armada laptops.
55 * - 30 July 1997. Added APM support.
56 * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX).
57 * Improved sync check logic.
58 * Vendor specific support routines.
59 */
60
61#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1992, 1993 Erik Forsberg.
3 * Copyright (c) 1996, 1997 Kazutaka YOKOTA.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 45 unchanged lines hidden (view full) ---

54 * HiNote UltraII/Latitude/Armada laptops.
55 * - 30 July 1997. Added APM support.
56 * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX).
57 * Improved sync check logic.
58 * Vendor specific support routines.
59 */
60
61#include <sys/cdefs.h>
62__FBSDID("$FreeBSD: head/sys/dev/atkbdc/psm.c 282734 2015-05-10 20:36:57Z rpaulo $");
62__FBSDID("$FreeBSD: head/sys/dev/atkbdc/psm.c 284320 2015-06-12 13:57:04Z glebius $");
63
64#include "opt_isa.h"
65#include "opt_psm.h"
66
67#include <sys/param.h>
68#include <sys/systm.h>
69#include <sys/kernel.h>
70#include <sys/module.h>

--- 386 unchanged lines hidden (view full) ---

457static int proc_synaptics(struct psm_softc *, packetbuf_t *,
458 mousestatus_t *, int *, int *, int *);
459static void proc_versapad(struct psm_softc *, packetbuf_t *,
460 mousestatus_t *, int *, int *, int *);
461static int tame_mouse(struct psm_softc *, packetbuf_t *, mousestatus_t *,
462 u_char *);
463
464/* vendor specific features */
63
64#include "opt_isa.h"
65#include "opt_psm.h"
66
67#include <sys/param.h>
68#include <sys/systm.h>
69#include <sys/kernel.h>
70#include <sys/module.h>

--- 386 unchanged lines hidden (view full) ---

457static int proc_synaptics(struct psm_softc *, packetbuf_t *,
458 mousestatus_t *, int *, int *, int *);
459static void proc_versapad(struct psm_softc *, packetbuf_t *,
460 mousestatus_t *, int *, int *, int *);
461static int tame_mouse(struct psm_softc *, packetbuf_t *, mousestatus_t *,
462 u_char *);
463
464/* vendor specific features */
465typedef int probefunc_t(KBDC, struct psm_softc *);
465enum probearg { PROBE, REINIT };
466typedef int probefunc_t(struct psm_softc *, enum probearg);
466
467static int mouse_id_proc1(KBDC, int, int, int *);
468static int mouse_ext_command(KBDC, int);
469
470static probefunc_t enable_groller;
471static probefunc_t enable_gmouse;
472static probefunc_t enable_aglide;
473static probefunc_t enable_kmouse;

--- 403 unchanged lines hidden (view full) ---

877 sc->unit);
878 return (FALSE);
879 }
880 empty_both_buffers(kbdc, 10); /* remove stray data if any */
881
882 /* Re-enable the mouse. */
883 for (i = 0; vendortype[i].probefunc != NULL; ++i)
884 if (vendortype[i].model == sc->hw.model)
467
468static int mouse_id_proc1(KBDC, int, int, int *);
469static int mouse_ext_command(KBDC, int);
470
471static probefunc_t enable_groller;
472static probefunc_t enable_gmouse;
473static probefunc_t enable_aglide;
474static probefunc_t enable_kmouse;

--- 403 unchanged lines hidden (view full) ---

878 sc->unit);
879 return (FALSE);
880 }
881 empty_both_buffers(kbdc, 10); /* remove stray data if any */
882
883 /* Re-enable the mouse. */
884 for (i = 0; vendortype[i].probefunc != NULL; ++i)
885 if (vendortype[i].model == sc->hw.model)
885 (*vendortype[i].probefunc)(sc->kbdc, NULL);
886 (*vendortype[i].probefunc)(sc, REINIT);
886
887 /* set mouse parameters */
888 if (mode != (mousemode_t *)NULL) {
889 if (mode->rate > 0)
890 mode->rate = set_mouse_sampling_rate(kbdc, mode->rate);
891 if (mode->resolution >= 0)
892 mode->resolution =
893 set_mouse_resolution(kbdc, mode->resolution);
894 set_mouse_scaling(kbdc, 1);
895 set_mouse_mode(kbdc);
887
888 /* set mouse parameters */
889 if (mode != (mousemode_t *)NULL) {
890 if (mode->rate > 0)
891 mode->rate = set_mouse_sampling_rate(kbdc, mode->rate);
892 if (mode->resolution >= 0)
893 mode->resolution =
894 set_mouse_resolution(kbdc, mode->resolution);
895 set_mouse_scaling(kbdc, 1);
896 set_mouse_mode(kbdc);
896
897 /*
898 * Trackpoint settings are lost on resume.
899 * Restore them here.
900 */
901 if (sc->tphw > 0)
902 set_trackpoint_parameters(sc);
903 }
904
905 /* Record sync on the next data packet we see. */
906 sc->flags |= PSM_NEED_SYNCBITS;
907
908 /* just check the status of the mouse */
909 if (get_mouse_status(kbdc, stat, 0, 3) < 3)
910 log(LOG_DEBUG, "psm%d: failed to get status (doinitialize).\n",

--- 472 unchanged lines hidden (view full) ---

1383 sc->hw.buttons = 2;
1384 i = GENERIC_MOUSE_ENTRY;
1385 } else {
1386 /* # of buttons */
1387 sc->hw.buttons = get_mouse_buttons(sc->kbdc);
1388
1389 /* other parameters */
1390 for (i = 0; vendortype[i].probefunc != NULL; ++i)
897 }
898
899 /* Record sync on the next data packet we see. */
900 sc->flags |= PSM_NEED_SYNCBITS;
901
902 /* just check the status of the mouse */
903 if (get_mouse_status(kbdc, stat, 0, 3) < 3)
904 log(LOG_DEBUG, "psm%d: failed to get status (doinitialize).\n",

--- 472 unchanged lines hidden (view full) ---

1377 sc->hw.buttons = 2;
1378 i = GENERIC_MOUSE_ENTRY;
1379 } else {
1380 /* # of buttons */
1381 sc->hw.buttons = get_mouse_buttons(sc->kbdc);
1382
1383 /* other parameters */
1384 for (i = 0; vendortype[i].probefunc != NULL; ++i)
1391 if ((*vendortype[i].probefunc)(sc->kbdc, sc)) {
1385 if ((*vendortype[i].probefunc)(sc, PROBE)) {
1392 if (verbose >= 2)
1393 printf("psm%d: found %s\n", unit,
1394 model_name(vendortype[i].model));
1395 break;
1396 }
1397 }
1398
1399 sc->hw.model = vendortype[i].model;

--- 2326 unchanged lines hidden (view full) ---

3726 if (set_mouse_resolution(kbdc, c) != c)
3727 return (FALSE);
3728 return (TRUE);
3729}
3730
3731#ifdef notyet
3732/* Logitech MouseMan Cordless II */
3733static int
1386 if (verbose >= 2)
1387 printf("psm%d: found %s\n", unit,
1388 model_name(vendortype[i].model));
1389 break;
1390 }
1391 }
1392
1393 sc->hw.model = vendortype[i].model;

--- 2326 unchanged lines hidden (view full) ---

3720 if (set_mouse_resolution(kbdc, c) != c)
3721 return (FALSE);
3722 return (TRUE);
3723}
3724
3725#ifdef notyet
3726/* Logitech MouseMan Cordless II */
3727static int
3734enable_lcordless(KDBC kbdc, struct psm_softc *sc)
3728enable_lcordless(struct psm_softc *sc, enum probearg arg)
3735{
3729{
3730 KBDC kbdc = sc->kbdc;
3736 int status[3];
3737 int ch;
3738
3739 if (!mouse_id_proc1(kbdc, PSMD_RES_HIGH, 2, status))
3740 return (FALSE);
3741 if (status[1] == PSMD_RES_HIGH)
3742 return (FALSE);
3743 ch = (status[0] & 0x07) - 1; /* channel # */

--- 4 unchanged lines hidden (view full) ---

3748 * status[2]: battery status? (0-100)
3749 */
3750 return (TRUE);
3751}
3752#endif /* notyet */
3753
3754/* Genius NetScroll Mouse, MouseSystems SmartScroll Mouse */
3755static int
3731 int status[3];
3732 int ch;
3733
3734 if (!mouse_id_proc1(kbdc, PSMD_RES_HIGH, 2, status))
3735 return (FALSE);
3736 if (status[1] == PSMD_RES_HIGH)
3737 return (FALSE);
3738 ch = (status[0] & 0x07) - 1; /* channel # */

--- 4 unchanged lines hidden (view full) ---

3743 * status[2]: battery status? (0-100)
3744 */
3745 return (TRUE);
3746}
3747#endif /* notyet */
3748
3749/* Genius NetScroll Mouse, MouseSystems SmartScroll Mouse */
3750static int
3756enable_groller(KBDC kbdc, struct psm_softc *sc)
3751enable_groller(struct psm_softc *sc, enum probearg arg)
3757{
3752{
3753 KBDC kbdc = sc->kbdc;
3758 int status[3];
3759
3760 /*
3761 * The special sequence to enable the fourth button and the
3762 * roller. Immediately after this sequence check status bytes.
3763 * if the mouse is NetScroll, the second and the third bytes are
3764 * '3' and 'D'.
3765 */

--- 12 unchanged lines hidden (view full) ---

3778 * byte 3 report rate (?)
3779 */
3780
3781 if (!mouse_id_proc1(kbdc, PSMD_RES_HIGH, 1, status))
3782 return (FALSE);
3783 if ((status[1] != '3') || (status[2] != 'D'))
3784 return (FALSE);
3785 /* FIXME: SmartScroll Mouse has 5 buttons! XXX */
3754 int status[3];
3755
3756 /*
3757 * The special sequence to enable the fourth button and the
3758 * roller. Immediately after this sequence check status bytes.
3759 * if the mouse is NetScroll, the second and the third bytes are
3760 * '3' and 'D'.
3761 */

--- 12 unchanged lines hidden (view full) ---

3774 * byte 3 report rate (?)
3775 */
3776
3777 if (!mouse_id_proc1(kbdc, PSMD_RES_HIGH, 1, status))
3778 return (FALSE);
3779 if ((status[1] != '3') || (status[2] != 'D'))
3780 return (FALSE);
3781 /* FIXME: SmartScroll Mouse has 5 buttons! XXX */
3786 if (sc != NULL)
3782 if (arg == PROBE)
3787 sc->hw.buttons = 4;
3788 return (TRUE);
3789}
3790
3791/* Genius NetMouse/NetMouse Pro, ASCII Mie Mouse, NetScroll Optical */
3792static int
3783 sc->hw.buttons = 4;
3784 return (TRUE);
3785}
3786
3787/* Genius NetMouse/NetMouse Pro, ASCII Mie Mouse, NetScroll Optical */
3788static int
3793enable_gmouse(KBDC kbdc, struct psm_softc *sc)
3789enable_gmouse(struct psm_softc *sc, enum probearg arg)
3794{
3790{
3791 KBDC kbdc = sc->kbdc;
3795 int status[3];
3796
3797 /*
3798 * The special sequence to enable the middle, "rubber" button.
3799 * Immediately after this sequence check status bytes.
3800 * if the mouse is NetMouse, NetMouse Pro, or ASCII MIE Mouse,
3801 * the second and the third bytes are '3' and 'U'.
3802 * NOTE: NetMouse reports that it has three buttons although it has

--- 5 unchanged lines hidden (view full) ---

3808 return (FALSE);
3809 if ((status[1] != '3') || (status[2] != 'U'))
3810 return (FALSE);
3811 return (TRUE);
3812}
3813
3814/* ALPS GlidePoint */
3815static int
3792 int status[3];
3793
3794 /*
3795 * The special sequence to enable the middle, "rubber" button.
3796 * Immediately after this sequence check status bytes.
3797 * if the mouse is NetMouse, NetMouse Pro, or ASCII MIE Mouse,
3798 * the second and the third bytes are '3' and 'U'.
3799 * NOTE: NetMouse reports that it has three buttons although it has

--- 5 unchanged lines hidden (view full) ---

3805 return (FALSE);
3806 if ((status[1] != '3') || (status[2] != 'U'))
3807 return (FALSE);
3808 return (TRUE);
3809}
3810
3811/* ALPS GlidePoint */
3812static int
3816enable_aglide(KBDC kbdc, struct psm_softc *sc)
3813enable_aglide(struct psm_softc *sc, enum probearg arg)
3817{
3814{
3815 KBDC kbdc = sc->kbdc;
3818 int status[3];
3819
3820 /*
3821 * The special sequence to obtain ALPS GlidePoint specific
3822 * information. Immediately after this sequence, status bytes will
3823 * contain something interesting.
3824 * NOTE: ALPS produces several models of GlidePoint. Some of those
3825 * do not respond to this sequence, thus, cannot be detected this way.

--- 4 unchanged lines hidden (view full) ---

3830 return (FALSE);
3831 if ((status[1] == PSMD_RES_LOW) || (status[2] == 100))
3832 return (FALSE);
3833 return (TRUE);
3834}
3835
3836/* Kensington ThinkingMouse/Trackball */
3837static int
3816 int status[3];
3817
3818 /*
3819 * The special sequence to obtain ALPS GlidePoint specific
3820 * information. Immediately after this sequence, status bytes will
3821 * contain something interesting.
3822 * NOTE: ALPS produces several models of GlidePoint. Some of those
3823 * do not respond to this sequence, thus, cannot be detected this way.

--- 4 unchanged lines hidden (view full) ---

3828 return (FALSE);
3829 if ((status[1] == PSMD_RES_LOW) || (status[2] == 100))
3830 return (FALSE);
3831 return (TRUE);
3832}
3833
3834/* Kensington ThinkingMouse/Trackball */
3835static int
3838enable_kmouse(KBDC kbdc, struct psm_softc *sc)
3836enable_kmouse(struct psm_softc *sc, enum probearg arg)
3839{
3840 static u_char rate[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
3837{
3838 static u_char rate[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
3839 KBDC kbdc = sc->kbdc;
3841 int status[3];
3842 int id1;
3843 int id2;
3844 int i;
3845
3846 id1 = get_aux_id(kbdc);
3847 if (set_mouse_sampling_rate(kbdc, 10) != 10)
3848 return (FALSE);

--- 34 unchanged lines hidden (view full) ---

3883 disable_aux_dev(kbdc);
3884 empty_aux_buffer(kbdc, 5);
3885
3886 return (TRUE);
3887}
3888
3889/* Logitech MouseMan+/FirstMouse+, IBM ScrollPoint Mouse */
3890static int
3840 int status[3];
3841 int id1;
3842 int id2;
3843 int i;
3844
3845 id1 = get_aux_id(kbdc);
3846 if (set_mouse_sampling_rate(kbdc, 10) != 10)
3847 return (FALSE);

--- 34 unchanged lines hidden (view full) ---

3882 disable_aux_dev(kbdc);
3883 empty_aux_buffer(kbdc, 5);
3884
3885 return (TRUE);
3886}
3887
3888/* Logitech MouseMan+/FirstMouse+, IBM ScrollPoint Mouse */
3889static int
3891enable_mmanplus(KBDC kbdc, struct psm_softc *sc)
3890enable_mmanplus(struct psm_softc *sc, enum probearg arg)
3892{
3891{
3892 KBDC kbdc = sc->kbdc;
3893 int data[3];
3894
3895 /* the special sequence to enable the fourth button and the roller. */
3896 /*
3897 * NOTE: for ScrollPoint to respond correctly, the SET_RESOLUTION
3898 * must be called exactly three times since the last RESET command
3899 * before this sequence. XXX
3900 */

--- 24 unchanged lines hidden (view full) ---

3925 return (FALSE);
3926 /* check d3-d0 in byte 2 */
3927 if (!MOUSE_PS2PLUS_CHECKBITS(data))
3928 return (FALSE);
3929 /* check p3-p0 */
3930 if (MOUSE_PS2PLUS_PACKET_TYPE(data) != 0)
3931 return (FALSE);
3932
3893 int data[3];
3894
3895 /* the special sequence to enable the fourth button and the roller. */
3896 /*
3897 * NOTE: for ScrollPoint to respond correctly, the SET_RESOLUTION
3898 * must be called exactly three times since the last RESET command
3899 * before this sequence. XXX
3900 */

--- 24 unchanged lines hidden (view full) ---

3925 return (FALSE);
3926 /* check d3-d0 in byte 2 */
3927 if (!MOUSE_PS2PLUS_CHECKBITS(data))
3928 return (FALSE);
3929 /* check p3-p0 */
3930 if (MOUSE_PS2PLUS_PACKET_TYPE(data) != 0)
3931 return (FALSE);
3932
3933 if (sc != NULL) {
3933 if (arg == PROBE) {
3934 sc->hw.hwid &= 0x00ff;
3935 sc->hw.hwid |= data[2] << 8; /* save model ID */
3936 }
3937
3938 /*
3939 * MouseMan+ (or FirstMouse+) is now in its native mode, in which
3940 * the wheel and the fourth button events are encoded in the
3941 * special data packet. The mouse may be put in the IntelliMouse mode
3942 * if it is initialized by the IntelliMouse's method.
3943 */
3944 return (TRUE);
3945}
3946
3947/* MS IntelliMouse Explorer */
3948static int
3934 sc->hw.hwid &= 0x00ff;
3935 sc->hw.hwid |= data[2] << 8; /* save model ID */
3936 }
3937
3938 /*
3939 * MouseMan+ (or FirstMouse+) is now in its native mode, in which
3940 * the wheel and the fourth button events are encoded in the
3941 * special data packet. The mouse may be put in the IntelliMouse mode
3942 * if it is initialized by the IntelliMouse's method.
3943 */
3944 return (TRUE);
3945}
3946
3947/* MS IntelliMouse Explorer */
3948static int
3949enable_msexplorer(KBDC kbdc, struct psm_softc *sc)
3949enable_msexplorer(struct psm_softc *sc, enum probearg arg)
3950{
3950{
3951 KBDC kbdc = sc->kbdc;
3951 static u_char rate0[] = { 200, 100, 80, };
3952 static u_char rate1[] = { 200, 200, 80, };
3953 int id;
3954 int i;
3955
3956 /*
3957 * This is needed for at least A4Tech X-7xx mice - they do not go
3958 * straight to Explorer mode, but need to be set to Intelli mode
3959 * first.
3960 */
3952 static u_char rate0[] = { 200, 100, 80, };
3953 static u_char rate1[] = { 200, 200, 80, };
3954 int id;
3955 int i;
3956
3957 /*
3958 * This is needed for at least A4Tech X-7xx mice - they do not go
3959 * straight to Explorer mode, but need to be set to Intelli mode
3960 * first.
3961 */
3961 enable_msintelli(kbdc, sc);
3962 enable_msintelli(sc, arg);
3962
3963 /* the special sequence to enable the extra buttons and the roller. */
3964 for (i = 0; i < sizeof(rate1)/sizeof(rate1[0]); ++i)
3965 if (set_mouse_sampling_rate(kbdc, rate1[i]) != rate1[i])
3966 return (FALSE);
3967 /* the device will give the genuine ID only after the above sequence */
3968 id = get_aux_id(kbdc);
3969 if (id != PSM_EXPLORER_ID)
3970 return (FALSE);
3971
3963
3964 /* the special sequence to enable the extra buttons and the roller. */
3965 for (i = 0; i < sizeof(rate1)/sizeof(rate1[0]); ++i)
3966 if (set_mouse_sampling_rate(kbdc, rate1[i]) != rate1[i])
3967 return (FALSE);
3968 /* the device will give the genuine ID only after the above sequence */
3969 id = get_aux_id(kbdc);
3970 if (id != PSM_EXPLORER_ID)
3971 return (FALSE);
3972
3972 if (sc != NULL) {
3973 if (arg == PROBE) {
3973 sc->hw.buttons = 5; /* IntelliMouse Explorer XXX */
3974 sc->hw.hwid = id;
3975 }
3976
3977 /*
3978 * XXX: this is a kludge to fool some KVM switch products
3979 * which think they are clever enough to know the 4-byte IntelliMouse
3980 * protocol, and assume any other protocols use 3-byte packets.

--- 6 unchanged lines hidden (view full) ---

3987 for (i = 0; i < sizeof(rate0)/sizeof(rate0[0]); ++i)
3988 if (set_mouse_sampling_rate(kbdc, rate0[i]) != rate0[i])
3989 break;
3990 get_aux_id(kbdc);
3991
3992 return (TRUE);
3993}
3994
3974 sc->hw.buttons = 5; /* IntelliMouse Explorer XXX */
3975 sc->hw.hwid = id;
3976 }
3977
3978 /*
3979 * XXX: this is a kludge to fool some KVM switch products
3980 * which think they are clever enough to know the 4-byte IntelliMouse
3981 * protocol, and assume any other protocols use 3-byte packets.

--- 6 unchanged lines hidden (view full) ---

3988 for (i = 0; i < sizeof(rate0)/sizeof(rate0[0]); ++i)
3989 if (set_mouse_sampling_rate(kbdc, rate0[i]) != rate0[i])
3990 break;
3991 get_aux_id(kbdc);
3992
3993 return (TRUE);
3994}
3995
3995/* MS IntelliMouse */
3996/*
3997 * MS IntelliMouse
3998 * Logitech MouseMan+ and FirstMouse+ will also respond to this
3999 * probe routine and act like IntelliMouse.
4000 */
3996static int
4001static int
3997enable_msintelli(KBDC kbdc, struct psm_softc *sc)
4002enable_msintelli(struct psm_softc *sc, enum probearg arg)
3998{
4003{
3999 /*
4000 * Logitech MouseMan+ and FirstMouse+ will also respond to this
4001 * probe routine and act like IntelliMouse.
4002 */
4003
4004 KBDC kbdc = sc->kbdc;
4004 static u_char rate[] = { 200, 100, 80, };
4005 int id;
4006 int i;
4007
4008 /* the special sequence to enable the third button and the roller. */
4009 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)
4010 if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
4011 return (FALSE);
4012 /* the device will give the genuine ID only after the above sequence */
4013 id = get_aux_id(kbdc);
4014 if (id != PSM_INTELLI_ID)
4015 return (FALSE);
4016
4005 static u_char rate[] = { 200, 100, 80, };
4006 int id;
4007 int i;
4008
4009 /* the special sequence to enable the third button and the roller. */
4010 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)
4011 if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
4012 return (FALSE);
4013 /* the device will give the genuine ID only after the above sequence */
4014 id = get_aux_id(kbdc);
4015 if (id != PSM_INTELLI_ID)
4016 return (FALSE);
4017
4017 if (sc != NULL) {
4018 if (arg == PROBE) {
4018 sc->hw.buttons = 3;
4019 sc->hw.hwid = id;
4020 }
4021
4022 return (TRUE);
4023}
4024
4019 sc->hw.buttons = 3;
4020 sc->hw.hwid = id;
4021 }
4022
4023 return (TRUE);
4024}
4025
4025/* A4 Tech 4D Mouse */
4026/*
4027 * A4 Tech 4D Mouse
4028 * Newer wheel mice from A4 Tech may use the 4D+ protocol.
4029 */
4026static int
4030static int
4027enable_4dmouse(KBDC kbdc, struct psm_softc *sc)
4031enable_4dmouse(struct psm_softc *sc, enum probearg arg)
4028{
4032{
4029 /*
4030 * Newer wheel mice from A4 Tech may use the 4D+ protocol.
4031 */
4032
4033 static u_char rate[] = { 200, 100, 80, 60, 40, 20 };
4033 static u_char rate[] = { 200, 100, 80, 60, 40, 20 };
4034 KBDC kbdc = sc->kbdc;
4034 int id;
4035 int i;
4036
4037 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)
4038 if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
4039 return (FALSE);
4040 id = get_aux_id(kbdc);
4041 /*
4042 * WinEasy 4D, 4 Way Scroll 4D: 6
4043 * Cable-Free 4D: 8 (4DPLUS)
4044 * WinBest 4D+, 4 Way Scroll 4D+: 8 (4DPLUS)
4045 */
4046 if (id != PSM_4DMOUSE_ID)
4047 return (FALSE);
4048
4035 int id;
4036 int i;
4037
4038 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)
4039 if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
4040 return (FALSE);
4041 id = get_aux_id(kbdc);
4042 /*
4043 * WinEasy 4D, 4 Way Scroll 4D: 6
4044 * Cable-Free 4D: 8 (4DPLUS)
4045 * WinBest 4D+, 4 Way Scroll 4D+: 8 (4DPLUS)
4046 */
4047 if (id != PSM_4DMOUSE_ID)
4048 return (FALSE);
4049
4049 if (sc != NULL) {
4050 if (arg == PROBE) {
4050 sc->hw.buttons = 3; /* XXX some 4D mice have 4? */
4051 sc->hw.hwid = id;
4052 }
4053
4054 return (TRUE);
4055}
4056
4051 sc->hw.buttons = 3; /* XXX some 4D mice have 4? */
4052 sc->hw.hwid = id;
4053 }
4054
4055 return (TRUE);
4056}
4057
4057/* A4 Tech 4D+ Mouse */
4058/*
4059 * A4 Tech 4D+ Mouse
4060 * Newer wheel mice from A4 Tech seem to use this protocol.
4061 * Older models are recognized as either 4D Mouse or IntelliMouse.
4062 */
4058static int
4063static int
4059enable_4dplus(KBDC kbdc, struct psm_softc *sc)
4064enable_4dplus(struct psm_softc *sc, enum probearg arg)
4060{
4065{
4061 /*
4062 * Newer wheel mice from A4 Tech seem to use this protocol.
4063 * Older models are recognized as either 4D Mouse or IntelliMouse.
4064 */
4066 KBDC kbdc = sc->kbdc;
4065 int id;
4066
4067 /*
4068 * enable_4dmouse() already issued the following ID sequence...
4069 static u_char rate[] = { 200, 100, 80, 60, 40, 20 };
4070 int i;
4071
4072 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)

--- 6 unchanged lines hidden (view full) ---

4079 case PSM_4DPLUS_ID:
4080 break;
4081 case PSM_4DPLUS_RFSW35_ID:
4082 break;
4083 default:
4084 return (FALSE);
4085 }
4086
4067 int id;
4068
4069 /*
4070 * enable_4dmouse() already issued the following ID sequence...
4071 static u_char rate[] = { 200, 100, 80, 60, 40, 20 };
4072 int i;
4073
4074 for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i)

--- 6 unchanged lines hidden (view full) ---

4081 case PSM_4DPLUS_ID:
4082 break;
4083 case PSM_4DPLUS_RFSW35_ID:
4084 break;
4085 default:
4086 return (FALSE);
4087 }
4088
4087 if (sc != NULL) {
4089 if (arg == PROBE) {
4088 sc->hw.buttons = (id == PSM_4DPLUS_ID) ? 4 : 3;
4089 sc->hw.hwid = id;
4090 }
4091
4092 return (TRUE);
4093}
4094
4095/* Synaptics Touchpad */

--- 442 unchanged lines hidden (view full) ---

4538 */
4539 if (sc->synhw.capAdvancedGestures && !(mode_byte & (1 << 5))) {
4540 mouse_ext_command(sc->kbdc, 3);
4541 set_mouse_sampling_rate(sc->kbdc, 0xc8);
4542 }
4543}
4544
4545static int
4090 sc->hw.buttons = (id == PSM_4DPLUS_ID) ? 4 : 3;
4091 sc->hw.hwid = id;
4092 }
4093
4094 return (TRUE);
4095}
4096
4097/* Synaptics Touchpad */

--- 442 unchanged lines hidden (view full) ---

4540 */
4541 if (sc->synhw.capAdvancedGestures && !(mode_byte & (1 << 5))) {
4542 mouse_ext_command(sc->kbdc, 3);
4543 set_mouse_sampling_rate(sc->kbdc, 0xc8);
4544 }
4545}
4546
4547static int
4546enable_synaptics(KBDC kbdc, struct psm_softc *sc)
4548enable_synaptics(struct psm_softc *sc, enum probearg arg)
4547{
4549{
4550 KBDC kbdc = sc->kbdc;
4548 synapticshw_t synhw;
4549 int status[3];
4550 int buttons;
4551
4552 VLOG(3, (LOG_DEBUG, "synaptics: BEGIN init\n"));
4553
4554 /*
4555 * Just to be on the safe side: this avoids troubles with

--- 267 unchanged lines hidden (view full) ---

4823 return (FALSE);
4824 if (get_mouse_status(kbdc, status, 0, 3) != 3)
4825 return (FALSE);
4826 if (!SYNAPTICS_VERSION_GE(synhw, 7, 5) && status[1] != 0x47) {
4827 printf(" Failed to read mode byte\n");
4828 return (FALSE);
4829 }
4830
4551 synapticshw_t synhw;
4552 int status[3];
4553 int buttons;
4554
4555 VLOG(3, (LOG_DEBUG, "synaptics: BEGIN init\n"));
4556
4557 /*
4558 * Just to be on the safe side: this avoids troubles with

--- 267 unchanged lines hidden (view full) ---

4826 return (FALSE);
4827 if (get_mouse_status(kbdc, status, 0, 3) != 3)
4828 return (FALSE);
4829 if (!SYNAPTICS_VERSION_GE(synhw, 7, 5) && status[1] != 0x47) {
4830 printf(" Failed to read mode byte\n");
4831 return (FALSE);
4832 }
4833
4831 if (sc != NULL)
4834 if (arg == PROBE)
4832 sc->synhw = synhw;
4833 if (!synaptics_support)
4834 return (FALSE);
4835
4835 sc->synhw = synhw;
4836 if (!synaptics_support)
4837 return (FALSE);
4838
4839 synaptics_set_mode(sc, synaptics_preferred_mode(sc));
4840
4841 if (trackpoint_support && synhw.capPassthrough) {
4842 synaptics_passthrough_on(sc);
4843 enable_trackpoint(sc, arg);
4844 synaptics_passthrough_off(sc);
4845 }
4846
4836 VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons));
4837
4847 VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons));
4848
4838 if (sc != NULL) {
4839 synaptics_set_mode(sc, synaptics_preferred_mode(sc));
4840 if (trackpoint_support && synhw.capPassthrough) {
4841 synaptics_passthrough_on(sc);
4842 enable_trackpoint(kbdc, sc);
4843 synaptics_passthrough_off(sc);
4844 }
4849 if (arg == PROBE) {
4845 /* Create sysctl tree. */
4846 synaptics_sysctl_create_tree(sc);
4847 sc->hw.buttons = buttons;
4848 }
4849
4850 return (TRUE);
4851}
4852

--- 228 unchanged lines hidden (view full) ---

5081 trackpoint_command(sc, 0x81, 0x5e, sc->tpinfo.ztime);
5082 if (sc->tpinfo.pts == 0x01)
5083 trackpoint_command(sc, 0x47, 0x2c, 0x01);
5084 if (sc->tpinfo.skipback == 0x01)
5085 trackpoint_command(sc, 0x47, 0x2d, 0x08);
5086}
5087
5088static int
4850 /* Create sysctl tree. */
4851 synaptics_sysctl_create_tree(sc);
4852 sc->hw.buttons = buttons;
4853 }
4854
4855 return (TRUE);
4856}
4857

--- 228 unchanged lines hidden (view full) ---

5086 trackpoint_command(sc, 0x81, 0x5e, sc->tpinfo.ztime);
5087 if (sc->tpinfo.pts == 0x01)
5088 trackpoint_command(sc, 0x47, 0x2c, 0x01);
5089 if (sc->tpinfo.skipback == 0x01)
5090 trackpoint_command(sc, 0x47, 0x2d, 0x08);
5091}
5092
5093static int
5089enable_trackpoint(KBDC kbdc, struct psm_softc *sc)
5094enable_trackpoint(struct psm_softc *sc, enum probearg arg)
5090{
5095{
5096 KBDC kbdc = sc->kbdc;
5091 int id;
5092
5093 if (send_aux_command(kbdc, 0xe1) != PSM_ACK ||
5094 read_aux_data(kbdc) != 0x01)
5095 return (FALSE);
5096 id = read_aux_data(kbdc);
5097 if (id < 0x01)
5098 return (FALSE);
5099 if (sc != NULL)
5100 sc->tphw = id;
5101 if (!trackpoint_support)
5102 return (FALSE);
5103
5097 int id;
5098
5099 if (send_aux_command(kbdc, 0xe1) != PSM_ACK ||
5100 read_aux_data(kbdc) != 0x01)
5101 return (FALSE);
5102 id = read_aux_data(kbdc);
5103 if (id < 0x01)
5104 return (FALSE);
5105 if (sc != NULL)
5106 sc->tphw = id;
5107 if (!trackpoint_support)
5108 return (FALSE);
5109
5104 if (sc != NULL) {
5105 /* Create sysctl tree. */
5110 if (arg == PROBE) {
5106 trackpoint_sysctl_create_tree(sc);
5111 trackpoint_sysctl_create_tree(sc);
5107
5108 /*
5109 * Don't overwrite hwid and buttons when we are
5110 * a guest device.
5111 */
5112 if (!sc->synhw.capPassthrough) {
5113 sc->hw.hwid = id;
5114 sc->hw.buttons = 3;
5115 }
5116 }
5117
5112 /*
5113 * Don't overwrite hwid and buttons when we are
5114 * a guest device.
5115 */
5116 if (!sc->synhw.capPassthrough) {
5117 sc->hw.hwid = id;
5118 sc->hw.buttons = 3;
5119 }
5120 }
5121
5122 set_trackpoint_parameters(sc);
5123
5118 return (TRUE);
5119}
5120
5121/* Interlink electronics VersaPad */
5122static int
5124 return (TRUE);
5125}
5126
5127/* Interlink electronics VersaPad */
5128static int
5123enable_versapad(KBDC kbdc, struct psm_softc *sc)
5129enable_versapad(struct psm_softc *sc, enum probearg arg)
5124{
5130{
5131 KBDC kbdc = sc->kbdc;
5125 int data[3];
5126
5127 set_mouse_resolution(kbdc, PSMD_RES_MEDIUM_HIGH); /* set res. 2 */
5128 set_mouse_sampling_rate(kbdc, 100); /* set rate 100 */
5129 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5130 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5131 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5132 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */

--- 194 unchanged lines hidden ---
5132 int data[3];
5133
5134 set_mouse_resolution(kbdc, PSMD_RES_MEDIUM_HIGH); /* set res. 2 */
5135 set_mouse_sampling_rate(kbdc, 100); /* set rate 100 */
5136 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5137 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5138 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
5139 set_mouse_scaling(kbdc, 1); /* set scale 1:1 */

--- 194 unchanged lines hidden ---