[PATCH xf86-input-synaptics v2 02/13] Allocate SynapticsHwStruct for local function use
Chase Douglas
chase.douglas at canonical.com
Thu Feb 9 18:24:46 PST 2012
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 at canonical.com>
---
src/synaptics.c | 22 +++++++++++++++-------
src/synapticsstr.h | 2 ++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/synaptics.c b/src/synaptics.c
index b9b4de6..03ed54d 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[] */
--
1.7.8.3
More information about the xorg-devel
mailing list