Commit 5aeaa3e6 authored by Sean Young's avatar Sean Young Committed by Dmitry Torokhov

media: ttpci: remove autorepeat handling and use timer_setup

Leave the autorepeat handling up to the input layer, and move
to the new timer API.

Compile tested only.
Signed-off-by: default avatarSean Young <sean@mess.org>
Acked-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a2c714e8
...@@ -93,7 +93,7 @@ struct infrared { ...@@ -93,7 +93,7 @@ struct infrared {
u8 inversion; u8 inversion;
u16 last_key; u16 last_key;
u16 last_toggle; u16 last_toggle;
u8 delay_timer_finished; bool keypressed;
}; };
......
...@@ -84,15 +84,16 @@ static u16 default_key_map [256] = { ...@@ -84,15 +84,16 @@ static u16 default_key_map [256] = {
/* key-up timer */ /* key-up timer */
static void av7110_emit_keyup(unsigned long parm) static void av7110_emit_keyup(struct timer_list *t)
{ {
struct infrared *ir = (struct infrared *) parm; struct infrared *ir = from_timer(ir, t, keyup_timer);
if (!ir || !test_bit(ir->last_key, ir->input_dev->key)) if (!ir || !ir->keypressed)
return; return;
input_report_key(ir->input_dev, ir->last_key, 0); input_report_key(ir->input_dev, ir->last_key, 0);
input_sync(ir->input_dev); input_sync(ir->input_dev);
ir->keypressed = false;
} }
...@@ -152,29 +153,18 @@ static void av7110_emit_key(unsigned long parm) ...@@ -152,29 +153,18 @@ static void av7110_emit_key(unsigned long parm)
return; return;
} }
if (timer_pending(&ir->keyup_timer)) { if (ir->keypressed &&
del_timer(&ir->keyup_timer); (ir->last_key != keycode || toggle != ir->last_toggle))
if (ir->last_key != keycode || toggle != ir->last_toggle) { input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
ir->delay_timer_finished = 0;
input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
input_event(ir->input_dev, EV_KEY, keycode, 1);
input_sync(ir->input_dev);
} else if (ir->delay_timer_finished) {
input_event(ir->input_dev, EV_KEY, keycode, 2);
input_sync(ir->input_dev);
}
} else {
ir->delay_timer_finished = 0;
input_event(ir->input_dev, EV_KEY, keycode, 1);
input_sync(ir->input_dev);
}
input_event(ir->input_dev, EV_KEY, keycode, 1);
input_sync(ir->input_dev);
ir->keypressed = true;
ir->last_key = keycode; ir->last_key = keycode;
ir->last_toggle = toggle; ir->last_toggle = toggle;
ir->keyup_timer.expires = jiffies + UP_TIMEOUT; mod_timer(&ir->keyup_timer, jiffies + UP_TIMEOUT);
add_timer(&ir->keyup_timer);
} }
...@@ -204,16 +194,6 @@ static void input_register_keys(struct infrared *ir) ...@@ -204,16 +194,6 @@ static void input_register_keys(struct infrared *ir)
ir->input_dev->keycodemax = ARRAY_SIZE(ir->key_map); ir->input_dev->keycodemax = ARRAY_SIZE(ir->key_map);
} }
/* called by the input driver after rep[REP_DELAY] ms */
static void input_repeat_key(unsigned long parm)
{
struct infrared *ir = (struct infrared *) parm;
ir->delay_timer_finished = 1;
}
/* check for configuration changes */ /* check for configuration changes */
int av7110_check_ir_config(struct av7110 *av7110, int force) int av7110_check_ir_config(struct av7110 *av7110, int force)
{ {
...@@ -333,8 +313,7 @@ int av7110_ir_init(struct av7110 *av7110) ...@@ -333,8 +313,7 @@ int av7110_ir_init(struct av7110 *av7110)
av_list[av_cnt++] = av7110; av_list[av_cnt++] = av7110;
av7110_check_ir_config(av7110, true); av7110_check_ir_config(av7110, true);
setup_timer(&av7110->ir.keyup_timer, av7110_emit_keyup, timer_setup(&av7110->ir.keyup_timer, av7110_emit_keyup, 0);
(unsigned long)&av7110->ir);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!input_dev) if (!input_dev)
...@@ -365,8 +344,13 @@ int av7110_ir_init(struct av7110 *av7110) ...@@ -365,8 +344,13 @@ int av7110_ir_init(struct av7110 *av7110)
input_free_device(input_dev); input_free_device(input_dev);
return err; return err;
} }
input_dev->timer.function = input_repeat_key;
input_dev->timer.data = (unsigned long) &av7110->ir; /*
* Input core's default autorepeat is 33 cps with 250 msec
* delay, let's adjust to numbers more suitable for remote
* control.
*/
input_enable_softrepeat(input_dev, 250, 125);
if (av_cnt == 1) { if (av_cnt == 1) {
e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops); e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment