Skip to content

Commit

Permalink
Input: hgpk - recalibration tweaks
Browse files Browse the repository at this point in the history
Disable the recalibration guard where new recalibrations are triggered
if we detect a packet too soon after calibrating - we found that this
results in erroneous recalibrations, and if the recalibration failed
then the rest of our badness-detection code will request another.

Add a module option disabling all of the recalibration code, in case
an OLPC deployment thinks all of the workarounds we have are doing
more damage than good and wants to experiment with them all disabled.

Based on work by Paul Fox.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Daniel Drake authored and Dmitry Torokhov committed Nov 15, 2010
1 parent 67f56bb commit 34caed2
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions drivers/input/mouse/hgpk.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ module_param(spew_delay, int, 0644);
MODULE_PARM_DESC(spew_delay,
"delay (ms) before recal after packet spew detected");

static int recal_guard_time = 2000;
static int recal_guard_time;
module_param(recal_guard_time, int, 0644);
MODULE_PARM_DESC(recal_guard_time,
"interval (ms) during which recal will be restarted if packet received");

static int post_interrupt_delay = 1000;
static int post_interrupt_delay = 40;
module_param(post_interrupt_delay, int, 0644);
MODULE_PARM_DESC(post_interrupt_delay,
"delay (ms) before recal after recal interrupt detected");

static bool autorecal = true;
module_param(autorecal, bool, 0644);
MODULE_PARM_DESC(autorecal, "enable recalibration in the driver");

static char hgpk_mode_name[16];
module_param_string(hgpk_mode, hgpk_mode_name, sizeof(hgpk_mode_name), 0644);
MODULE_PARM_DESC(hgpk_mode,
Expand Down Expand Up @@ -642,6 +646,13 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)
if (psmouse->model < HGPK_MODEL_C)
return 0;

if (!autorecal) {
hgpk_dbg(psmouse, "recalibrations disabled, ignoring\n");
return 0;
}

hgpk_dbg(psmouse, "recalibrating touchpad..\n");

/* we don't want to race with the irq handler, nor with resyncs */
psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);

Expand All @@ -662,13 +673,17 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)

psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);

if (tpdebug)
hgpk_dbg(psmouse, "touchpad reactivated\n");

/*
* After we recalibrate, we shouldn't get any packets for 2s. If
* we do, it's likely that someone's finger was on the touchpad.
* If someone's finger *was* on the touchpad, it's probably
* miscalibrated. So, we should schedule another recalibration
* If we get packets right away after recalibrating, it's likely
* that a finger was on the touchpad. If so, it's probably
* miscalibrated, so we optionally schedule another.
*/
priv->recalib_window = jiffies + msecs_to_jiffies(recal_guard_time);
if (recal_guard_time)
priv->recalib_window = jiffies +
msecs_to_jiffies(recal_guard_time);

return 0;
}
Expand Down Expand Up @@ -898,8 +913,6 @@ static void hgpk_recalib_work(struct work_struct *work)
struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);
struct psmouse *psmouse = priv->psmouse;

hgpk_dbg(psmouse, "recalibrating touchpad..\n");

if (hgpk_force_recalibrate(psmouse))
hgpk_err(psmouse, "recalibration failed!\n");
}
Expand Down

0 comments on commit 34caed2

Please sign in to comment.