summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-02-07 15:23:43 -0800
committerChase Douglas <chase.douglas@canonical.com>2012-02-10 13:20:48 -0800
commita78d55d021c9cd3be6501760d6fca3464ea6dec8 (patch)
tree5d7141cba5a15926986d3803d488a0bb88d63f4d /src
parente5cd694ed1028b94fdbe10d76dbea1e03455f8fb (diff)
Allocate SynapticsHwStruct for local function use
SynapticsHwStruct (SHS) will soon include ValuatorMasks, which can only be allocated on the heap. The input driver callbacks are called in signal context, so we can't instantiate a new SHS when that occurs. Since we only ever need one SHS, allocate one at device init time and use it in place of local SHS instances. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/synaptics.c22
-rw-r--r--src/synapticsstr.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index a4c1e5a..e7deb9b 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -934,6 +934,7 @@ DeviceClose(DeviceIntPtr dev)
TimerFree(priv->timer);
priv->timer = NULL;
free_shm_data(priv);
+ SynapticsHwStateFree(&priv->local_hw_state);
return RetValue;
}
@@ -1179,8 +1180,15 @@ no_touch:
free(axes_labels);
+ priv->local_hw_state = SynapticsHwStateAlloc(priv);
+ if (!priv->local_hw_state)
+ return !Success;
+
if (!alloc_shm_data(pInfo))
+ {
+ free(priv->local_hw_state);
return !Success;
+ }
InitDeviceProperties(pInfo);
XIRegisterPropertyHandler(pInfo->dev, SetProperty, NULL, NULL);
@@ -1310,15 +1318,15 @@ timerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
{
InputInfoPtr pInfo = arg;
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
- struct SynapticsHwState hw;
+ struct SynapticsHwState *hw = priv->local_hw_state;
int delay;
int sigstate;
sigstate = xf86BlockSIGIO();
priv->hwState.millis += now - priv->timer_time;
- hw = priv->hwState;
- delay = HandleState(pInfo, &hw, hw.millis, TRUE);
+ *hw = priv->hwState;
+ delay = HandleState(pInfo, hw, hw->millis, TRUE);
priv->timer_time = now;
priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, pInfo);
@@ -1353,13 +1361,13 @@ static void
ReadInput(InputInfoPtr pInfo)
{
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
- struct SynapticsHwState hw;
+ struct SynapticsHwState *hw = priv->local_hw_state;
int delay = 0;
Bool newDelay = FALSE;
- while (SynapticsGetHwState(pInfo, priv, &hw)) {
- priv->hwState = hw;
- delay = HandleState(pInfo, &hw, hw.millis, FALSE);
+ while (SynapticsGetHwState(pInfo, priv, hw)) {
+ priv->hwState = *hw;
+ delay = HandleState(pInfo, hw, hw->millis, FALSE);
newDelay = TRUE;
}
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index d3b8607..fff159c 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -201,6 +201,8 @@ typedef struct _SynapticsPrivateRec
struct CommData comm;
+ struct SynapticsHwState *local_hw_state; /* used in place of local hw state variables */
+
Bool absolute_events; /* post absolute motion events instead of relative */
SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */
int hist_index; /* Last added entry in move_hist[] */