From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Stelian Pop <stelian@popies.net>, linux-input@vger.kernel.org
Subject: Re: [PATCH v3] Input: appletouch - driver refactoring
Date: Mon, 27 Oct 2008 23:03:55 -0400 [thread overview]
Message-ID: <20081028030355.GA2898@anvil.corenet.prv> (raw)
In-Reply-To: <1223891135.24954.1.camel@johannes.berg>
On Mon, Oct 13, 2008 at 11:45:35AM +0200, Johannes Berg wrote:
> On Sun, 2008-10-12 at 18:03 +0200, Stelian Pop wrote:
> > The appletouch driver has grown up from supporting only a couple of
> > touchpads into supporting many touchpads, which can have different
> > number of sensors, different aspect ratios etc.
> >
> > This patch cleans up the current driver code and makes it easy to
> > support the features of each different touchpad.
> >
> > As a side effect, this patch also modifies the 'Y' multiplication factor
> > of the 'geyser3' and 'geyser4' touchpads (found on Core Duo and Core2
> > Duo MacBook and MacBook Pro laptops) in order to make the touchpad
> > output match the aspect ratio of the touchpad (Y factor changed from 43
> > to 64).
>
> Looks good, the only thing I can find to complain about is that you
> modify
>
>
> > +static struct atp_info geyser1_info = {
> > + .xsensors = 16, /* will be set to 26 on 17" */
>
> those static variables ;)
>
> Considering these devices aren't available outside of apple laptops and
> those always come with exactly one, I don't think it's much of a
> problem.
>
How about if we do this:
Input: appletouch - small fixup to Stelians patch
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/mouse/appletouch.c | 67 ++++++++++++++++++++------------------
1 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index ea36f14..454b961 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -43,6 +43,7 @@
*/
struct atp_info {
int xsensors; /* number of X sensors */
+ int xsensors_17; /* 17" models have more sensors */
int ysensors; /* number of Y sensors */
int xfact; /* X multiplication factor */
int yfact; /* Y multiplication factor */
@@ -53,8 +54,9 @@ struct atp_info {
static void atp_complete_geyser_1_2(struct urb *urb);
static void atp_complete_geyser_3_4(struct urb *urb);
-static struct atp_info fountain_info = {
- .xsensors = 16, /* will be set to 26 on 17" */
+static const struct atp_info fountain_info = {
+ .xsensors = 16,
+ .xsensors_17 = 26,
.ysensors = 16,
.xfact = 64,
.yfact = 43,
@@ -62,8 +64,9 @@ static struct atp_info fountain_info = {
.callback = atp_complete_geyser_1_2,
};
-static struct atp_info geyser1_info = {
- .xsensors = 16, /* will be set to 26 on 17" */
+static const struct atp_info geyser1_info = {
+ .xsensors = 16,
+ .xsensors_17 = 26,
.ysensors = 16,
.xfact = 64,
.yfact = 43,
@@ -71,8 +74,9 @@ static struct atp_info geyser1_info = {
.callback = atp_complete_geyser_1_2,
};
-static struct atp_info geyser2_info = {
- .xsensors = 15, /* will be set to 20 on 17" */
+static const struct atp_info geyser2_info = {
+ .xsensors = 15,
+ .xsensors_17 = 20,
.ysensors = 9,
.xfact = 64,
.yfact = 43,
@@ -80,7 +84,7 @@ static struct atp_info geyser2_info = {
.callback = atp_complete_geyser_1_2,
};
-static struct atp_info geyser3_info = {
+static const struct atp_info geyser3_info = {
.xsensors = 20,
.ysensors = 10,
.xfact = 64,
@@ -89,7 +93,7 @@ static struct atp_info geyser3_info = {
.callback = atp_complete_geyser_3_4,
};
-static struct atp_info geyser4_info = {
+static const struct atp_info geyser4_info = {
.xsensors = 20,
.ysensors = 10,
.xfact = 64,
@@ -194,7 +198,7 @@ struct atp {
struct urb *urb; /* usb request block */
u8 *data; /* transferred data */
struct input_dev *input; /* input dev */
- struct atp_info *info; /* touchpad model */
+ const struct atp_info *info; /* touchpad model */
bool open;
bool valid; /* are the samples valid? */
bool size_detect_done;
@@ -421,6 +425,25 @@ static int atp_status_check(struct urb *urb)
return ATP_URB_STATUS_SUCCESS;
}
+static void atp_detect_size(struct atp *dev)
+{
+ int i;
+
+ /* 17" Powerbooks have extra X sensors */
+ for (i = dev->info->xsensors; i < ATP_XSENSORS; i++) {
+ if (dev->xy_cur[i]) {
+
+ printk(KERN_INFO "appletouch: 17\" model detected.\n");
+
+ input_set_abs_params(dev->input, ABS_X, 0,
+ (dev->info->xsensors_17 - 1) *
+ dev->info->xfact - 1,
+ ATP_FUZZ, 0);
+ break;
+ }
+ }
+}
+
/*
* USB interrupt callback functions
*/
@@ -487,28 +510,8 @@ static void atp_complete_geyser_1_2(struct urb *urb)
memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
/* Perform size detection, if not done already */
- if (!dev->size_detect_done) {
-
- /* 17" Powerbooks have extra X sensors */
- for (i = dev->info->xsensors; i < ATP_XSENSORS; i++) {
- if (!dev->xy_cur[i])
- continue;
-
- printk(KERN_INFO
- "appletouch: 17\" model detected.\n");
-
- if (dev->info == &geyser2_info)
- dev->info->xsensors = 20;
- else
- dev->info->xsensors = 26;
-
- input_set_abs_params(dev->input, ABS_X, 0,
- (dev->info->xsensors - 1) *
- dev->info->xfact - 1,
- ATP_FUZZ, 0);
- break;
- }
-
+ if (unlikely(!dev->size_detect_done)) {
+ atp_detect_size(dev);
dev->size_detect_done = 1;
goto exit;
}
@@ -756,7 +759,7 @@ static int atp_probe(struct usb_interface *iface,
struct usb_endpoint_descriptor *endpoint;
int int_in_endpointAddr = 0;
int i, error = -ENOMEM;
- struct atp_info *info = (struct atp_info *)id->driver_info;
+ const struct atp_info *info = (const struct atp_info *)id->driver_info;
/* set up the endpoint information */
/* use only the first interrupt-in endpoint */
--
Dmitry
next prev parent reply other threads:[~2008-10-28 3:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 8:49 [PATCH] appletouch driver refactoring Stelian Pop
2008-10-11 3:21 ` Dmitry Torokhov
2008-10-12 14:41 ` Stelian Pop
2008-10-12 14:44 ` [PATCH] Input: appletouch - " Stelian Pop
2008-10-12 14:54 ` Johannes Berg
2008-10-12 16:00 ` Stelian Pop
2008-10-12 16:03 ` [PATCH v3] " Stelian Pop
2008-10-13 9:45 ` Johannes Berg
2008-10-14 2:57 ` Dmitry Torokhov
2008-10-14 8:10 ` Johannes Berg
2008-10-28 3:03 ` Dmitry Torokhov [this message]
2008-10-28 7:23 ` Johannes Berg
2008-10-29 16:01 ` Stelian Pop
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=20081028030355.GA2898@anvil.corenet.prv \
--to=dmitry.torokhov@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-input@vger.kernel.org \
--cc=stelian@popies.net \
/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).