From: "Jean-François Dagenais" <jeff.dagenais@gmail.com>
To: michael.hennerich@analog.com
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
device-drivers-devel@blackfin.uclinux.org,
"Jean-François Dagenais" <jeff.dagenais@gmail.com>
Subject: [PATCH 2/2] input: ad714x - use stage qty to split max_coord for wheel algo
Date: Thu, 26 Apr 2012 13:17:19 -0400 [thread overview]
Message-ID: <1335460639-1362-2-git-send-email-jeff.dagenais@gmail.com> (raw)
In-Reply-To: <1335460639-1362-1-git-send-email-jeff.dagenais@gmail.com>
Using "end_stage - start_stage" yields "number of used stages -1".
This makes the divisor smaller, hence the dividend greater.
So for example, with 8 (0..7) stages, and max_coord of 1024, the
algo should figure out that 1024 should be split in 8, so 8 slices
of 128. Instead, dividing by 7 will give bigger slices of 146.
While adding these "slices", when stages 7 and 0 are weighted to
determine the abs_pos, a dead-zone appears where we are stuck at
max_coord because of the bigger "slices" and the if that follows:
"if abs_pos > max_coord, then abs_pos = max_coord"
Hence this commit, which re-uses variable "stag_num" initialized with
the number of used stages.
Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com>
---
drivers/input/misc/ad714x.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index 2cf26e5..29f5d10 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -477,8 +477,7 @@ static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx)
ad714x->sensor_val[first_before] +
ad714x->sensor_val[first_after];
- sw->abs_pos = ((hw->max_coord / (hw->end_stage - hw->start_stage)) *
- a_param) / b_param;
+ sw->abs_pos = ((hw->max_coord / stage_num) * a_param) / b_param;
if (sw->abs_pos > hw->max_coord)
sw->abs_pos = hw->max_coord;
--
1.7.9
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-04-26 17:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 17:17 [PATCH 1/2] input: ad714x - fix divide by 0 error in wheel cal_abs_pos Jean-François Dagenais
2012-04-26 17:17 ` Jean-François Dagenais [this message]
2012-04-27 1:33 ` [PATCH 2/2] input: ad714x - use stage qty to split max_coord for wheel algo Jean-François Dagenais
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335460639-1362-2-git-send-email-jeff.dagenais@gmail.com \
--to=jeff.dagenais@gmail.com \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=michael.hennerich@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).