From a469585b1cd41e6efd5c2746a655feb840525e5c Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Mon, 7 Jun 2010 16:32:23 -0300 Subject: V4L/DVB: ir-core: convert em28xx to not use ir-functions.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c Signed-off-by: David Härdeman Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/em28xx/em28xx-input.c | 65 ++++++++----------------------- 1 file changed, 16 insertions(+), 49 deletions(-) (limited to 'drivers/media/video/em28xx/em28xx-input.c') diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index 5c3fd9411b1f..dd6d528998b1 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c @@ -65,17 +65,14 @@ struct em28xx_ir_poll_result { struct em28xx_IR { struct em28xx *dev; struct input_dev *input; - struct ir_input_state ir; char name[32]; char phys[32]; /* poll external decoder */ int polling; struct delayed_work work; - unsigned int last_toggle:1; unsigned int full_code:1; unsigned int last_readcount; - unsigned int repeat_interval; int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); @@ -291,7 +288,6 @@ static int em2874_polling_getkey(struct em28xx_IR *ir, static void em28xx_ir_handle_key(struct em28xx_IR *ir) { int result; - int do_sendkey = 0; struct em28xx_ir_poll_result poll_result; /* read the registers containing the IR status */ @@ -306,52 +302,28 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir) ir->last_readcount, poll_result.rc_address, poll_result.rc_data[0]); - if (ir->dev->chip_id == CHIP_ID_EM2874) { + if (poll_result.read_count > 0 && + poll_result.read_count != ir->last_readcount) { + if (ir->full_code) + ir_keydown(ir->input, + poll_result.rc_address << 8 | + poll_result.rc_data[0], + poll_result.toggle_bit); + else + ir_keydown(ir->input, + poll_result.rc_data[0], + poll_result.toggle_bit); + } + + if (ir->dev->chip_id == CHIP_ID_EM2874) /* The em2874 clears the readcount field every time the register is read. The em2860/2880 datasheet says that it is supposed to clear the readcount, but it doesn't. So with the em2874, we are looking for a non-zero read count as opposed to a readcount that is incrementing */ ir->last_readcount = 0; - } - - if (poll_result.read_count == 0) { - /* The button has not been pressed since the last read */ - } else if (ir->last_toggle != poll_result.toggle_bit) { - /* A button has been pressed */ - dprintk("button has been pressed\n"); - ir->last_toggle = poll_result.toggle_bit; - ir->repeat_interval = 0; - do_sendkey = 1; - } else if (poll_result.toggle_bit == ir->last_toggle && - poll_result.read_count > 0 && - poll_result.read_count != ir->last_readcount) { - /* The button is still being held down */ - dprintk("button being held down\n"); - - /* Debouncer for first keypress */ - if (ir->repeat_interval++ > 9) { - /* Start repeating after 1 second */ - do_sendkey = 1; - } - } - - if (do_sendkey) { - dprintk("sending keypress\n"); - - if (ir->full_code) - ir_input_keydown(ir->input, &ir->ir, - poll_result.rc_address << 8 | - poll_result.rc_data[0]); - else - ir_input_keydown(ir->input, &ir->ir, - poll_result.rc_data[0]); - - ir_input_nokey(ir->input, &ir->ir); - } - - ir->last_readcount = poll_result.read_count; - return; + else + ir->last_readcount = poll_result.read_count; } static void em28xx_ir_work(struct work_struct *work) @@ -466,11 +438,6 @@ int em28xx_ir_init(struct em28xx *dev) usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); strlcat(ir->phys, "/input0", sizeof(ir->phys)); - /* Set IR protocol */ - err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER); - if (err < 0) - goto err_out_free; - input_dev->name = ir->name; input_dev->phys = ir->phys; input_dev->id.bustype = BUS_USB; -- cgit v1.2.3 From 603044d883d610acdb44daecf94b0fca48880b5c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 27 Jun 2010 08:32:11 -0300 Subject: V4L/DVB: em28xx-input: Don't generate one debug message for every get_key read Instead of generating one printk for every IR read, prints it only when count is different from the last count. While here, as this code is called on every 100ms during the runtime lifetime, do some performance optimization, assuming that, under normal circumstances, it is unlikely that the driver would get a new key/key repeat on every poll. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/em28xx/em28xx-input.c | 33 ++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'drivers/media/video/em28xx/em28xx-input.c') diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index dd6d528998b1..6759cd5570dd 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c @@ -292,18 +292,15 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir) /* read the registers containing the IR status */ result = ir->get_key(ir, &poll_result); - if (result < 0) { + if (unlikely(result < 0)) { dprintk("ir->get_key() failed %d\n", result); return; } - dprintk("ir->get_key result tb=%02x rc=%02x lr=%02x data=%02x%02x\n", - poll_result.toggle_bit, poll_result.read_count, - ir->last_readcount, poll_result.rc_address, - poll_result.rc_data[0]); - - if (poll_result.read_count > 0 && - poll_result.read_count != ir->last_readcount) { + if (unlikely(poll_result.read_count != ir->last_readcount)) { + dprintk("%s: toggle: %d, count: %d, key 0x%02x%02x\n", __func__, + poll_result.toggle_bit, poll_result.read_count, + poll_result.rc_address, poll_result.rc_data[0]); if (ir->full_code) ir_keydown(ir->input, poll_result.rc_address << 8 | @@ -313,17 +310,17 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir) ir_keydown(ir->input, poll_result.rc_data[0], poll_result.toggle_bit); - } - if (ir->dev->chip_id == CHIP_ID_EM2874) - /* The em2874 clears the readcount field every time the - register is read. The em2860/2880 datasheet says that it - is supposed to clear the readcount, but it doesn't. So with - the em2874, we are looking for a non-zero read count as - opposed to a readcount that is incrementing */ - ir->last_readcount = 0; - else - ir->last_readcount = poll_result.read_count; + if (ir->dev->chip_id == CHIP_ID_EM2874) + /* The em2874 clears the readcount field every time the + register is read. The em2860/2880 datasheet says that it + is supposed to clear the readcount, but it doesn't. So with + the em2874, we are looking for a non-zero read count as + opposed to a readcount that is incrementing */ + ir->last_readcount = 0; + else + ir->last_readcount = poll_result.read_count; + } } static void em28xx_ir_work(struct work_struct *work) -- cgit v1.2.3