~jderose/ubuntu/saucy/xserver-xorg-input-synaptics/clickpad

« back to all changes in this revision

Viewing changes to src/psmcomm.c

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2012-05-21 14:14:49 UTC
  • mfrom: (0.3.14 sid)
  • Revision ID: package-import@ubuntu.com-20120521141449-xj02s01b4b9yx2f1
Tags: 1.6.1-1ubuntu1
* Merged from Debian unstable
* Refreshed patches for indentation changes
  - 101_resolution_detect_option.patch
  - 118_quell_error_msg.patch
  - 124_syndaemon_events.patch
  - 125_option_rec_revert.patch
* Add temporary patches, for upstream git commits on synaptics-1.6-branch
* Fix memory corruption by driver (LP: #941953) FDo #49439
 - 201-Avoid-out-of-bounds-access-by-running-num_active_tou.patch
 - 202-Ignore-pre-existing-touches.patch
* Fix FDo #49966
 - 203-Fix-coasting-for-negative-ScrollDelta.patch
* Fix jumpy cursor after suspend/resume
 - 204-Reset-open-slots-array-on-device-disable.patch
* Fix another resume bug
 - 205-Reset-hw-x-y-to-INT_MIN-and-skip-HandleState-until-w.patch
* Fix division by 0 or infinite loop with zero scroll distance FDo #49965
 - 206-Don-t-allow-for-scroll-distances-of-0-49965.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#include "synproto.h"
48
48
#include "synaptics.h"
49
49
#include "synapticsstr.h"
50
 
#include "ps2comm.h"                        /* ps2_print_ident() */
 
50
#include "ps2comm.h"            /* ps2_print_ident() */
51
51
#include <xf86.h>
52
52
 
53
53
#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
57
57
 * See also the SYN_ID_* macros
58
58
 */
59
59
static Bool
60
 
psm_synaptics_identify(int fd, synapticshw_t *ident)
 
60
psm_synaptics_identify(int fd, synapticshw_t * ident)
61
61
{
62
62
    int ret;
63
63
 
64
64
    SYSCALL(ret = ioctl(fd, MOUSE_SYN_GETHWINFO, ident));
65
65
    if (ret == 0)
66
 
        return TRUE;
 
66
        return TRUE;
67
67
    else
68
 
        return FALSE;
 
68
        return FALSE;
69
69
}
70
70
 
71
71
/* This define is used in a ioctl but not in mouse.h :/ */
84
84
     */
85
85
    SYSCALL(ret = ioctl(pInfo->fd, MOUSE_SETLEVEL, &level));
86
86
    if (ret != 0) {
87
 
        xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
88
 
        return FALSE;
 
87
        xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
 
88
        return FALSE;
89
89
    }
90
90
    SYSCALL(ret = ioctl(pInfo->fd, MOUSE_GETHWINFO, &mhw));
91
91
    if (ret != 0) {
92
 
        xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n", pInfo->name);
93
 
        return FALSE;
 
92
        xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n",
 
93
                    pInfo->name);
 
94
        return FALSE;
94
95
    }
95
96
 
96
97
    if (mhw.model == MOUSE_MODEL_SYNAPTICS) {
97
 
        return TRUE;
98
 
    } else {
99
 
        xf86IDrvMsg(pInfo, X_ERROR, "%s Found no Synaptics, found Mouse model %d instead\n",
100
 
                pInfo->name, mhw.model);
101
 
        return FALSE;
 
98
        return TRUE;
 
99
    }
 
100
    else {
 
101
        xf86IDrvMsg(pInfo, X_ERROR,
 
102
                    "%s Found no Synaptics, found Mouse model %d instead\n",
 
103
                    pInfo->name, mhw.model);
 
104
        return FALSE;
102
105
    }
103
106
}
104
107
 
105
108
static void
106
 
convert_hw_info(const synapticshw_t *psm_ident, struct PS2SynapticsHwInfo *synhw)
 
109
convert_hw_info(const synapticshw_t * psm_ident,
 
110
                struct PS2SynapticsHwInfo *synhw)
107
111
{
108
112
    memset(synhw, 0, sizeof(*synhw));
109
113
    synhw->model_id = ((psm_ident->infoRot180 << 23) |
110
 
                       (psm_ident->infoPortrait << 22) |
111
 
                       (psm_ident->infoSensor << 16) |
112
 
                       (psm_ident->infoHardware << 9) |
113
 
                       (psm_ident->infoNewAbs << 7) |
114
 
                       (psm_ident->capPen << 6) |
115
 
                       (psm_ident->infoSimplC << 5) |
116
 
                       (psm_ident->infoGeometry));
 
114
                       (psm_ident->infoPortrait << 22) |
 
115
                       (psm_ident->infoSensor << 16) |
 
116
                       (psm_ident->infoHardware << 9) |
 
117
                       (psm_ident->infoNewAbs << 7) |
 
118
                       (psm_ident->capPen << 6) |
 
119
                       (psm_ident->infoSimplC << 5) |
 
120
                       (psm_ident->infoGeometry));
117
121
    synhw->capabilities = ((psm_ident->capExtended << 23) |
118
 
                           (psm_ident->capPassthrough << 7) |
119
 
                           (psm_ident->capSleep << 4) |
120
 
                           (psm_ident->capFourButtons << 3) |
121
 
                           (psm_ident->capMultiFinger << 1) |
122
 
                           (psm_ident->capPalmDetect));
 
122
                           (psm_ident->capPassthrough << 7) |
 
123
                           (psm_ident->capSleep << 4) |
 
124
                           (psm_ident->capFourButtons << 3) |
 
125
                           (psm_ident->capMultiFinger << 1) |
 
126
                           (psm_ident->capPalmDetect));
123
127
    synhw->ext_cap = 0;
124
128
    synhw->identity = ((psm_ident->infoMajor) |
125
 
                       (0x47 << 8) |
126
 
                       (psm_ident->infoMinor << 16));
 
129
                       (0x47 << 8) | (psm_ident->infoMinor << 16));
127
130
}
128
131
 
129
132
static Bool
133
136
    struct PS2SynapticsHwInfo *synhw;
134
137
    SynapticsPrivate *priv;
135
138
 
136
 
    priv = (SynapticsPrivate *)pInfo->private;
 
139
    priv = (SynapticsPrivate *) pInfo->private;
137
140
 
138
 
    if(!priv->proto_data)
 
141
    if (!priv->proto_data)
139
142
        priv->proto_data = calloc(1, sizeof(struct PS2SynapticsHwInfo));
140
 
    synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;
 
143
    synhw = (struct PS2SynapticsHwInfo *) priv->proto_data;
141
144
 
142
145
    /* is the synaptics touchpad active? */
143
146
    if (!PSMQueryIsSynaptics(pInfo))
144
 
        return FALSE;
 
147
        return FALSE;
145
148
 
146
149
    xf86IDrvMsg(pInfo, X_PROBED, "synaptics touchpad found\n");
147
150
 
148
151
    if (!psm_synaptics_identify(pInfo->fd, &psm_ident))
149
 
        return FALSE;
 
152
        return FALSE;
150
153
 
151
154
    convert_hw_info(&psm_ident, synhw);
152
155
 
157
160
 
158
161
static Bool
159
162
PSMReadHwState(InputInfoPtr pInfo,
160
 
               struct CommData *comm, struct SynapticsHwState *hwRet)
 
163
               struct CommData *comm, struct SynapticsHwState *hwRet)
161
164
{
162
165
    return PS2ReadHwStateProto(pInfo, &psm_proto_operations, comm, hwRet);
163
166
}