* [RFC] psmouse: add support for 4th button using the 4th bit @ 2007-04-02 20:48 Aristeu Rozanski 2007-04-03 14:39 ` Dmitry Torokhov 0 siblings, 1 reply; 10+ messages in thread From: Aristeu Rozanski @ 2007-04-02 20:48 UTC (permalink / raw) To: dmitry.torokhov; +Cc: linux-input Some mice like the Cortron Trackball use the fourth bit of the first byte (yes, that one that the protocol tells to be always 1, oh well) to represent the fourth button. This patch adds an option to use the fourth bit to represent the fourth button. Please comment on this and please keep me on Cc list, I'm not subscribed to linux-input. --- drivers/input/mouse/psmouse-base.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- linus-2.6.orig/drivers/input/mouse/psmouse-base.c +++ linus-2.6/drivers/input/mouse/psmouse-base.c @@ -64,6 +64,13 @@ static unsigned int psmouse_resync_time; module_param_named(resync_time, psmouse_resync_time, uint, 0644); MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never)."); +static unsigned int psmouse_4th_bit_as_button; +module_param_named(4th_bit_as_button, psmouse_4th_bit_as_button, uint, 0); +MODULE_PARM_DESC(4th_bit_as_button, "Interpret the 4th bit of the first byte " + "as 4th button. Some mice like Cortron Trackballs use the " + "4th bit (which should be always set) of the first byte as " + "4th button"); + PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO, NULL, psmouse_attr_show_protocol, psmouse_attr_set_protocol); @@ -176,6 +183,14 @@ static psmouse_ret_t psmouse_process_byt packet[1] |= (packet[0] & 0x40) << 1; } + /* + * Use the 4th bit of the first package as button + */ + if (psmouse_4th_bit_as_button) { + input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1); + packet[0] |= 0x08; + } + /* * Generic PS/2 Mouse */ @@ -643,6 +658,9 @@ static int psmouse_extensions(struct psm psmouse_reset(psmouse); } + if (psmouse_4th_bit_as_button) + set_bit(BTN_SIDE, psmouse->dev->keybit); + return PSMOUSE_PS2; } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-04-02 20:48 [RFC] psmouse: add support for 4th button using the 4th bit Aristeu Rozanski @ 2007-04-03 14:39 ` Dmitry Torokhov 2007-04-03 14:42 ` Aristeu Rozanski 0 siblings, 1 reply; 10+ messages in thread From: Dmitry Torokhov @ 2007-04-03 14:39 UTC (permalink / raw) To: Aristeu Rozanski; +Cc: linux-input Hi Aristeu, On 4/2/07, Aristeu Rozanski <arozansk@redhat.com> wrote: > Some mice like the Cortron Trackball use the fourth bit of the first byte > (yes, that one that the protocol tells to be always 1, oh well) to represent > the fourth button. This patch adds an option to use the fourth bit to > represent the fourth button. > > Please comment on this and please keep me on Cc list, I'm not subscribed to > linux-input. > Do you know if there is a way (like a magic knock) that would allow to identify Cortron's devices? I don't like the module option too much, given the fact that it will affect all devices. Maybe we should define Cortron protocol instead and activate it manually via sysfs? -- Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-04-03 14:39 ` Dmitry Torokhov @ 2007-04-03 14:42 ` Aristeu Rozanski 2007-04-03 15:05 ` Dmitry Torokhov 0 siblings, 1 reply; 10+ messages in thread From: Aristeu Rozanski @ 2007-04-03 14:42 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Hi Dmitry, > Do you know if there is a way (like a magic knock) that would allow to > identify Cortron's devices? I don't like the module option too much, > given the fact that it will affect all devices. Maybe we should define > Cortron protocol instead and activate it manually via sysfs? there's no way to detect this Cortron device, it was my first try. Hm, the new protocol/sysfs idea seems to be much better, I didn't know that was possible. I'll rework the patch and resubmit. Thanks! -- Aristeu ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-04-03 14:42 ` Aristeu Rozanski @ 2007-04-03 15:05 ` Dmitry Torokhov 2007-04-03 15:23 ` Aristeu Rozanski 2007-05-08 18:53 ` Aristeu Rozanski 0 siblings, 2 replies; 10+ messages in thread From: Dmitry Torokhov @ 2007-04-03 15:05 UTC (permalink / raw) To: Aristeu Rozanski; +Cc: linux-input On 4/3/07, Aristeu Rozanski <arozansk@redhat.com> wrote: > Hi Dmitry, > > Do you know if there is a way (like a magic knock) that would allow to > > identify Cortron's devices? I don't like the module option too much, > > given the fact that it will affect all devices. Maybe we should define > > Cortron protocol instead and activate it manually via sysfs? > there's no way to detect this Cortron device, it was my first try. That's unfortunate. BTW, is this your observation or did you ask Cortron and this was their response? > Hm, the > new protocol/sysfs idea seems to be much better, I didn't know that was > possible. I'll rework the patch and resubmit. You'd need to add something like this to psmouse_protocols[]: { .type = PSMOUSE_CORTRON, .name = "CortronPS/2", .alias = "cortps", .detect = cortron_detect, }, and then model cortron_detect after ps2bare_detect (where you don't actually detect anything, just force protocol). -- Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-04-03 15:05 ` Dmitry Torokhov @ 2007-04-03 15:23 ` Aristeu Rozanski 2007-05-08 18:53 ` Aristeu Rozanski 1 sibling, 0 replies; 10+ messages in thread From: Aristeu Rozanski @ 2007-04-03 15:23 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input > That's unfortunate. BTW, is this your observation or did you ask > Cortron and this was their response? The customer got in touch with Cortron about this and Cortron told it's not possible to detect it. I can try talking with them to make sure it's the case. > You'd need to add something like this to psmouse_protocols[]: > > { > .type = PSMOUSE_CORTRON, > .name = "CortronPS/2", > .alias = "cortps", > .detect = cortron_detect, > }, > > and then model cortron_detect after ps2bare_detect (where you don't > actually detect anything, just force protocol). ok! Thanks, -- Aristeu ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-04-03 15:05 ` Dmitry Torokhov 2007-04-03 15:23 ` Aristeu Rozanski @ 2007-05-08 18:53 ` Aristeu Rozanski 2007-05-09 14:36 ` Dmitry Torokhov 1 sibling, 1 reply; 10+ messages in thread From: Aristeu Rozanski @ 2007-05-08 18:53 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input, Chris Williams Hi Dmitry, > You'd need to add something like this to psmouse_protocols[]: > > { > .type = PSMOUSE_CORTRON, > .name = "CortronPS/2", > .alias = "cortps", > .detect = cortron_detect, > }, > > and then model cortron_detect after ps2bare_detect (where you don't > actually detect anything, just force protocol). we asked Cortron again about a possible auto-detection sequence but they didn't implemented anything in this matter. So I updated the patch according your recomendations and Chris tested again with the Trackball, with success. If you're ok with that, I'll resubmit it with proper description/signed-off-by header. --- linus-2.6.orig/drivers/input/mouse/psmouse-base.c +++ linus-2.6/drivers/input/mouse/psmouse-base.c @@ -177,6 +177,15 @@ static psmouse_ret_t psmouse_process_byt } /* + * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first + * byte. + */ + if (psmouse->type == PSMOUSE_CORTRON) { + input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1); + packet[0] |= 0x08; + } + +/* * Generic PS/2 Mouse */ @@ -538,6 +547,20 @@ static int ps2bare_detect(struct psmouse return 0; } +/* + * Cortron PS/2 protocol detection. There's no special way to detect it, so it + * must be forced by sysfs protocol writing. + */ +static int cortron_detect(struct psmouse *psmouse, int set_properties) +{ + if (set_properties) { + psmouse->vendor = "Cortron"; + psmouse->name = "PS/2 Trackball"; + set_bit(BTN_SIDE, psmouse->dev->keybit); + } + + return 0; +} /* * psmouse_extensions() probes for any extensions to the basic PS/2 protocol @@ -655,6 +678,12 @@ static const struct psmouse_protocol psm .detect = ps2bare_detect, }, { + .type = PSMOUSE_CORTRON, + .name = "CortronPS/2", + .alias = "cortps", + .detect = cortron_detect, + }, + { .type = PSMOUSE_PS2PP, .name = "PS2++", .alias = "logitech", --- linus-2.6.orig/drivers/input/mouse/psmouse.h +++ linus-2.6/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ struct psmouse { enum psmouse_type { PSMOUSE_NONE, PSMOUSE_PS2, + PSMOUSE_CORTRON, PSMOUSE_PS2PP, PSMOUSE_THINKPS, PSMOUSE_GENPS, ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] psmouse: add support for 4th button using the 4th bit 2007-05-08 18:53 ` Aristeu Rozanski @ 2007-05-09 14:36 ` Dmitry Torokhov 2007-05-09 14:53 ` [PATCH] " Aristeu Rozanski 0 siblings, 1 reply; 10+ messages in thread From: Dmitry Torokhov @ 2007-05-09 14:36 UTC (permalink / raw) To: Aristeu Rozanski; +Cc: linux-input, Chris Williams Hi Aristeu, On 5/8/07, Aristeu Rozanski <arozansk@redhat.com> wrote: > Hi Dmitry, > > You'd need to add something like this to psmouse_protocols[]: > > > > { > > .type = PSMOUSE_CORTRON, > > .name = "CortronPS/2", > > .alias = "cortps", > > .detect = cortron_detect, > > }, > > > > and then model cortron_detect after ps2bare_detect (where you don't > > actually detect anything, just force protocol). > we asked Cortron again about a possible auto-detection sequence but they > didn't implemented anything in this matter. So I updated the patch > according your recomendations and Chris tested again with the Trackball, > with success. If you're ok with that, I'll resubmit it with proper > description/signed-off-by header. > Looks good, please resend. There may be issues with box losing manually set protocols when coming out of suspend but that's for another patch. Thank you. -- Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] psmouse: add support for 4th button using the 4th bit 2007-05-09 14:36 ` Dmitry Torokhov @ 2007-05-09 14:53 ` Aristeu Rozanski 2007-05-09 15:39 ` Dmitry Torokhov 0 siblings, 1 reply; 10+ messages in thread From: Aristeu Rozanski @ 2007-05-09 14:53 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input, Chris Williams Cortron PS/2 Trackballs (700-0001A) reports the 4th button using the 4th bit of the first packet (yes, it breaks the protocol). This patch adds an extra protocol to generate BTN_SIDE based on the 4th bit. There's no way to detect those trackballs using any kind of special sequence, thus the protocol is only available if selected writing 'protocol' file in sysfs, e.g.: echo -n "cortps" >/sys/devices/platform/i8042/serio1/protocol Signed-off-by: Aristeu Rozanski <arozansk@redhat.com> --- linus-2.6.orig/drivers/input/mouse/psmouse-base.c +++ linus-2.6/drivers/input/mouse/psmouse-base.c @@ -177,6 +177,15 @@ static psmouse_ret_t psmouse_process_byt } /* + * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first + * byte. + */ + if (psmouse->type == PSMOUSE_CORTRON) { + input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1); + packet[0] |= 0x08; + } + +/* * Generic PS/2 Mouse */ @@ -538,6 +547,20 @@ static int ps2bare_detect(struct psmouse return 0; } +/* + * Cortron PS/2 protocol detection. There's no special way to detect it, so it + * must be forced by sysfs protocol writing. + */ +static int cortron_detect(struct psmouse *psmouse, int set_properties) +{ + if (set_properties) { + psmouse->vendor = "Cortron"; + psmouse->name = "PS/2 Trackball"; + set_bit(BTN_SIDE, psmouse->dev->keybit); + } + + return 0; +} /* * psmouse_extensions() probes for any extensions to the basic PS/2 protocol @@ -655,6 +678,12 @@ static const struct psmouse_protocol psm .detect = ps2bare_detect, }, { + .type = PSMOUSE_CORTRON, + .name = "CortronPS/2", + .alias = "cortps", + .detect = cortron_detect, + }, + { .type = PSMOUSE_PS2PP, .name = "PS2++", .alias = "logitech", --- linus-2.6.orig/drivers/input/mouse/psmouse.h +++ linus-2.6/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ struct psmouse { enum psmouse_type { PSMOUSE_NONE, PSMOUSE_PS2, + PSMOUSE_CORTRON, PSMOUSE_PS2PP, PSMOUSE_THINKPS, PSMOUSE_GENPS, ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] psmouse: add support for 4th button using the 4th bit 2007-05-09 14:53 ` [PATCH] " Aristeu Rozanski @ 2007-05-09 15:39 ` Dmitry Torokhov 2007-05-09 15:49 ` Aristeu Rozanski 0 siblings, 1 reply; 10+ messages in thread From: Dmitry Torokhov @ 2007-05-09 15:39 UTC (permalink / raw) To: Aristeu Rozanski; +Cc: linux-input, Chris Williams On 5/9/07, Aristeu Rozanski <arozansk@redhat.com> wrote: > --- linus-2.6.orig/drivers/input/mouse/psmouse.h > +++ linus-2.6/drivers/input/mouse/psmouse.h > @@ -78,6 +78,7 @@ struct psmouse { > enum psmouse_type { > PSMOUSE_NONE, > PSMOUSE_PS2, > + PSMOUSE_CORTRON, > PSMOUSE_PS2PP, > PSMOUSE_THINKPS, > PSMOUSE_GENPS, > I moved PSMOUSE_CORTRON to the end of the list - psmouse type is exported to userspace as input_dev.id.product and so we should not change existing types. -- Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] psmouse: add support for 4th button using the 4th bit 2007-05-09 15:39 ` Dmitry Torokhov @ 2007-05-09 15:49 ` Aristeu Rozanski 0 siblings, 0 replies; 10+ messages in thread From: Aristeu Rozanski @ 2007-05-09 15:49 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input, Chris Williams > >--- linus-2.6.orig/drivers/input/mouse/psmouse.h > >+++ linus-2.6/drivers/input/mouse/psmouse.h > >@@ -78,6 +78,7 @@ struct psmouse { > > enum psmouse_type { > > PSMOUSE_NONE, > > PSMOUSE_PS2, > >+ PSMOUSE_CORTRON, > > PSMOUSE_PS2PP, > > PSMOUSE_THINKPS, > > PSMOUSE_GENPS, > > > > I moved PSMOUSE_CORTRON to the end of the list - psmouse type is > exported to userspace as input_dev.id.product and so we should not > change existing types. ok! -- Aristeu ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-05-09 15:49 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-04-02 20:48 [RFC] psmouse: add support for 4th button using the 4th bit Aristeu Rozanski 2007-04-03 14:39 ` Dmitry Torokhov 2007-04-03 14:42 ` Aristeu Rozanski 2007-04-03 15:05 ` Dmitry Torokhov 2007-04-03 15:23 ` Aristeu Rozanski 2007-05-08 18:53 ` Aristeu Rozanski 2007-05-09 14:36 ` Dmitry Torokhov 2007-05-09 14:53 ` [PATCH] " Aristeu Rozanski 2007-05-09 15:39 ` Dmitry Torokhov 2007-05-09 15:49 ` Aristeu Rozanski
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).