Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Am Montag, den 04.04.2005, 00:45 -0500 schrieb Dmitry Torokhov: > Hi Kenan, > [..] > > If I do "echo -n 50 > resolution" "0xe8 0x01" is sent. I don't know if > > this is correct for "usual" PS/2-devices but for the lifebook it's > > wrong. > > > > For the lifebook the parameters are as following: > > > > 50cpi <=> 0x00 > > 100cpi <=> 0x01 > > 200cpi <=> 0x02 > > 400cpi <=> 0x03 > > > > "Classic" PS/2 protocol specifies available resolutions of 1, 2, 4 and 8 > units per mm which gives you 25, 50, 100 and 200 cpi respectively. I am > surprised that Lifebook simply doubles the rates, but if it does I guess > the patch below will suffice. Yes -- exactly. That was what I was thinking about. I was just not shure whether it is lifebook specific or not. I haven't tested the patch yet. But by inspecting the code it looks good ;-) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Am Montag, den 04.04.2005, 00:45 -0500 schrieb Dmitry Torokhov: Hi Kenan, [..] If I do echo -n 50 resolution 0xe8 0x01 is sent. I don't know if this is correct for usual PS/2-devices but for the lifebook it's wrong. For the lifebook the parameters are as following: 50cpi = 0x00 100cpi = 0x01 200cpi = 0x02 400cpi = 0x03 Classic PS/2 protocol specifies available resolutions of 1, 2, 4 and 8 units per mm which gives you 25, 50, 100 and 200 cpi respectively. I am surprised that Lifebook simply doubles the rates, but if it does I guess the patch below will suffice. Yes -- exactly. That was what I was thinking about. I was just not shure whether it is lifebook specific or not. I haven't tested the patch yet. But by inspecting the code it looks good ;-) - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Hi Kenan, On Sunday 03 April 2005 14:49, Kenan Esau wrote: > Patches 1-3 are fine. > Thank you very much for testing the patches. Based on the feedback I received I am goping to drop that DMI patch - does not save enough to justify the ifdefs... > Protocol switching via sysfs works too but if I switch from LBPS/2 to > PS/2 the device name changes from "/dev/event1" to "/dev/event2" -- is > this intended? Yes - we in fact getting somewhat a "new" device with new capabilities so the driver unregisters old input device and creates a new one. I strongly believe that we should not change input device attributes "on fly". > If I do "echo -n 50 > resolution" "0xe8 0x01" is sent. I don't know if > this is correct for "usual" PS/2-devices but for the lifebook it's > wrong. > > For the lifebook the parameters are as following: > > 50cpi <=> 0x00 > 100cpi <=> 0x01 > 200cpi <=> 0x02 > 400cpi <=> 0x03 > "Classic" PS/2 protocol specifies available resolutions of 1, 2, 4 and 8 units per mm which gives you 25, 50, 100 and 200 cpi respectively. I am surprised that Lifebook simply doubles the rates, but if it does I guess the patch below will suffice. -- Dmitry === Input: apparently Lifebook touchscreens have double resolution compared to "classic" PS/2 mice, provide appropriate resolution setting handler. Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]> lifebook.c | 12 1 files changed, 12 insertions(+) Index: dtor/drivers/input/mouse/lifebook.c === --- dtor.orig/drivers/input/mouse/lifebook.c +++ dtor/drivers/input/mouse/lifebook.c @@ -82,6 +82,17 @@ static int lifebook_absolute_mode(struct return 0; } +static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) +{ + unsigned char params[] = { 0, 1, 2, 2, 3 }; + + if (resolution == 0 || resolution > 400) + resolution = 400; + + ps2_command(>ps2dev, [resolution / 100], PSMOUSE_CMD_SETRES); + psmouse->resolution = 50 << params[resolution / 100]; +} + static void lifebook_disconnect(struct psmouse *psmouse) { psmouse_reset(psmouse); @@ -114,6 +125,7 @@ int lifebook_init(struct psmouse *psmous input_set_abs_params(>dev, ABS_Y, 0, 1024, 0, 0); psmouse->protocol_handler = lifebook_process_byte; + psmouse->set_resolution = lifebook_set_resolution; psmouse->disconnect = lifebook_disconnect; psmouse->reconnect = lifebook_absolute_mode; psmouse->pktsize = 3; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Patches 1-3 are fine. Protocol switching via sysfs works too but if I switch from LBPS/2 to PS/2 the device name changes from "/dev/event1" to "/dev/event2" -- is this intended? If I do "echo -n 50 > resolution" "0xe8 0x01" is sent. I don't know if this is correct for "usual" PS/2-devices but for the lifebook it's wrong. For the lifebook the parameters are as following: 50cpi <=> 0x00 100cpi <=> 0x01 200cpi <=> 0x02 400cpi <=> 0x03 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Patches 1-3 are fine. Protocol switching via sysfs works too but if I switch from LBPS/2 to PS/2 the device name changes from /dev/event1 to /dev/event2 -- is this intended? If I do echo -n 50 resolution 0xe8 0x01 is sent. I don't know if this is correct for usual PS/2-devices but for the lifebook it's wrong. For the lifebook the parameters are as following: 50cpi = 0x00 100cpi = 0x01 200cpi = 0x02 400cpi = 0x03 - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] psmouse: dynamic protocol switching via sysfs
Hi Kenan, On Sunday 03 April 2005 14:49, Kenan Esau wrote: Patches 1-3 are fine. Thank you very much for testing the patches. Based on the feedback I received I am goping to drop that DMI patch - does not save enough to justify the ifdefs... Protocol switching via sysfs works too but if I switch from LBPS/2 to PS/2 the device name changes from /dev/event1 to /dev/event2 -- is this intended? Yes - we in fact getting somewhat a new device with new capabilities so the driver unregisters old input device and creates a new one. I strongly believe that we should not change input device attributes on fly. If I do echo -n 50 resolution 0xe8 0x01 is sent. I don't know if this is correct for usual PS/2-devices but for the lifebook it's wrong. For the lifebook the parameters are as following: 50cpi = 0x00 100cpi = 0x01 200cpi = 0x02 400cpi = 0x03 Classic PS/2 protocol specifies available resolutions of 1, 2, 4 and 8 units per mm which gives you 25, 50, 100 and 200 cpi respectively. I am surprised that Lifebook simply doubles the rates, but if it does I guess the patch below will suffice. -- Dmitry === Input: apparently Lifebook touchscreens have double resolution compared to classic PS/2 mice, provide appropriate resolution setting handler. Signed-off-by: Dmitry Torokhov [EMAIL PROTECTED] lifebook.c | 12 1 files changed, 12 insertions(+) Index: dtor/drivers/input/mouse/lifebook.c === --- dtor.orig/drivers/input/mouse/lifebook.c +++ dtor/drivers/input/mouse/lifebook.c @@ -82,6 +82,17 @@ static int lifebook_absolute_mode(struct return 0; } +static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) +{ + unsigned char params[] = { 0, 1, 2, 2, 3 }; + + if (resolution == 0 || resolution 400) + resolution = 400; + + ps2_command(psmouse-ps2dev, params[resolution / 100], PSMOUSE_CMD_SETRES); + psmouse-resolution = 50 params[resolution / 100]; +} + static void lifebook_disconnect(struct psmouse *psmouse) { psmouse_reset(psmouse); @@ -114,6 +125,7 @@ int lifebook_init(struct psmouse *psmous input_set_abs_params(psmouse-dev, ABS_Y, 0, 1024, 0, 0); psmouse-protocol_handler = lifebook_process_byte; + psmouse-set_resolution = lifebook_set_resolution; psmouse-disconnect = lifebook_disconnect; psmouse-reconnect = lifebook_absolute_mode; psmouse-pktsize = 3; - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] psmouse: dynamic protocol switching via sysfs
=== Input: psmouse - export protocol as a sysfs per-device attribute. Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]> drivers/input/mouse/psmouse-base.c | 291 ++--- drivers/input/mouse/psmouse.h |1 drivers/input/serio/serio.c| 44 + include/linux/serio.h |6 4 files changed, 290 insertions(+), 52 deletions(-) Index: dtor/drivers/input/serio/serio.c === --- dtor.orig/drivers/input/serio/serio.c +++ dtor/drivers/input/serio/serio.c @@ -43,6 +43,7 @@ MODULE_LICENSE("GPL"); EXPORT_SYMBOL(serio_interrupt); EXPORT_SYMBOL(__serio_register_port); EXPORT_SYMBOL(serio_unregister_port); +EXPORT_SYMBOL(serio_unregister_child_port); EXPORT_SYMBOL(__serio_unregister_port_delayed); EXPORT_SYMBOL(__serio_register_driver); EXPORT_SYMBOL(serio_unregister_driver); @@ -90,12 +91,19 @@ static void serio_bind_driver(struct ser down_write(_bus.subsys.rwsem); if (serio_match_port(drv->id_table, serio)) { + /* make sure parent is not about to change */ + if (serio->parent) + down(>parent->drv_sem); + serio->dev.driver = >driver; if (drv->connect(serio, drv)) { serio->dev.driver = NULL; goto out; } device_bind_driver(>dev); + + if (serio->parent) + up(>parent->drv_sem); } out: up_write(_bus.subsys.rwsem); @@ -150,12 +158,12 @@ static void serio_queue_event(void *obje spin_lock_irqsave(_event_lock, flags); /* -* Scan event list for the other events for the same serio port, +* Scan event list for the other events for the same serio port, * starting with the most recent one. If event is the same we * do not need add new one. If event is of different type we * need to add this event and should not look further because * we need to preseve sequence of distinct events. -*/ +*/ list_for_each_entry_reverse(event, _event_list, node) { if (event->object == object) { if (event->type == event_type) @@ -614,6 +622,19 @@ void serio_unregister_port(struct serio } /* + * Safely unregisters child port if one is present. + */ +void serio_unregister_child_port(struct serio *serio) +{ + down(_sem); + if (serio->child) { + serio_disconnect_port(serio->child); + serio_destroy_port(serio->child); + } + up(_sem); +} + +/* * Submits register request to kseriod for subsequent execution. * Can be used when it is not obvious whether the serio_sem is * taken or not and when delayed execution is feasible. @@ -669,8 +690,18 @@ static int serio_driver_probe(struct dev { struct serio *serio = to_serio_port(dev); struct serio_driver *drv = to_serio_driver(dev->driver); + int result; + + /* make sure parent is not about to change */ + if (serio->parent) + down(>parent->drv_sem); + + result = drv->connect(serio, drv); + + if (serio->parent) + up(>parent->drv_sem); - return drv->connect(serio, drv); + return result; } static int serio_driver_remove(struct device *dev) @@ -678,7 +709,14 @@ static int serio_driver_remove(struct de struct serio *serio = to_serio_port(dev); struct serio_driver *drv = to_serio_driver(dev->driver); + if (serio->parent) + down(>parent->drv_sem); + drv->disconnect(serio); + + if (serio->parent) + up(>parent->drv_sem); + return 0; } Index: dtor/drivers/input/mouse/psmouse.h === --- dtor.orig/drivers/input/mouse/psmouse.h +++ dtor/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ enum psmouse_type { PSMOUSE_SYNAPTICS, PSMOUSE_ALPS, PSMOUSE_LIFEBOOK, + PSMOUSE_AUTO/* This one should always be last */ }; int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); Index: dtor/include/linux/serio.h === --- dtor.orig/include/linux/serio.h +++ dtor/include/linux/serio.h @@ -83,6 +83,7 @@ static inline void serio_register_port(s } void serio_unregister_port(struct serio *serio); +void serio_unregister_child_port(struct serio *serio); void __serio_unregister_port_delayed(struct serio *serio, struct module *owner); static inline void serio_unregister_port_delayed(struct serio *serio) { @@ -153,6 +154,11 @@ static inline int serio_pin_driver(struc return down_interruptible(>drv_sem); } +static inline void serio_pin_driver_uninterruptible(struct
[PATCH 4/4] psmouse: dynamic protocol switching via sysfs
=== Input: psmouse - export protocol as a sysfs per-device attribute. Signed-off-by: Dmitry Torokhov [EMAIL PROTECTED] drivers/input/mouse/psmouse-base.c | 291 ++--- drivers/input/mouse/psmouse.h |1 drivers/input/serio/serio.c| 44 + include/linux/serio.h |6 4 files changed, 290 insertions(+), 52 deletions(-) Index: dtor/drivers/input/serio/serio.c === --- dtor.orig/drivers/input/serio/serio.c +++ dtor/drivers/input/serio/serio.c @@ -43,6 +43,7 @@ MODULE_LICENSE(GPL); EXPORT_SYMBOL(serio_interrupt); EXPORT_SYMBOL(__serio_register_port); EXPORT_SYMBOL(serio_unregister_port); +EXPORT_SYMBOL(serio_unregister_child_port); EXPORT_SYMBOL(__serio_unregister_port_delayed); EXPORT_SYMBOL(__serio_register_driver); EXPORT_SYMBOL(serio_unregister_driver); @@ -90,12 +91,19 @@ static void serio_bind_driver(struct ser down_write(serio_bus.subsys.rwsem); if (serio_match_port(drv-id_table, serio)) { + /* make sure parent is not about to change */ + if (serio-parent) + down(serio-parent-drv_sem); + serio-dev.driver = drv-driver; if (drv-connect(serio, drv)) { serio-dev.driver = NULL; goto out; } device_bind_driver(serio-dev); + + if (serio-parent) + up(serio-parent-drv_sem); } out: up_write(serio_bus.subsys.rwsem); @@ -150,12 +158,12 @@ static void serio_queue_event(void *obje spin_lock_irqsave(serio_event_lock, flags); /* -* Scan event list for the other events for the same serio port, +* Scan event list for the other events for the same serio port, * starting with the most recent one. If event is the same we * do not need add new one. If event is of different type we * need to add this event and should not look further because * we need to preseve sequence of distinct events. -*/ +*/ list_for_each_entry_reverse(event, serio_event_list, node) { if (event-object == object) { if (event-type == event_type) @@ -614,6 +622,19 @@ void serio_unregister_port(struct serio } /* + * Safely unregisters child port if one is present. + */ +void serio_unregister_child_port(struct serio *serio) +{ + down(serio_sem); + if (serio-child) { + serio_disconnect_port(serio-child); + serio_destroy_port(serio-child); + } + up(serio_sem); +} + +/* * Submits register request to kseriod for subsequent execution. * Can be used when it is not obvious whether the serio_sem is * taken or not and when delayed execution is feasible. @@ -669,8 +690,18 @@ static int serio_driver_probe(struct dev { struct serio *serio = to_serio_port(dev); struct serio_driver *drv = to_serio_driver(dev-driver); + int result; + + /* make sure parent is not about to change */ + if (serio-parent) + down(serio-parent-drv_sem); + + result = drv-connect(serio, drv); + + if (serio-parent) + up(serio-parent-drv_sem); - return drv-connect(serio, drv); + return result; } static int serio_driver_remove(struct device *dev) @@ -678,7 +709,14 @@ static int serio_driver_remove(struct de struct serio *serio = to_serio_port(dev); struct serio_driver *drv = to_serio_driver(dev-driver); + if (serio-parent) + down(serio-parent-drv_sem); + drv-disconnect(serio); + + if (serio-parent) + up(serio-parent-drv_sem); + return 0; } Index: dtor/drivers/input/mouse/psmouse.h === --- dtor.orig/drivers/input/mouse/psmouse.h +++ dtor/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ enum psmouse_type { PSMOUSE_SYNAPTICS, PSMOUSE_ALPS, PSMOUSE_LIFEBOOK, + PSMOUSE_AUTO/* This one should always be last */ }; int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); Index: dtor/include/linux/serio.h === --- dtor.orig/include/linux/serio.h +++ dtor/include/linux/serio.h @@ -83,6 +83,7 @@ static inline void serio_register_port(s } void serio_unregister_port(struct serio *serio); +void serio_unregister_child_port(struct serio *serio); void __serio_unregister_port_delayed(struct serio *serio, struct module *owner); static inline void serio_unregister_port_delayed(struct serio *serio) { @@ -153,6 +154,11 @@ static inline int serio_pin_driver(struc return down_interruptible(serio-drv_sem); } +static inline