aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-input.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-06-07 15:32:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 13:53:19 -0400
commita469585b1cd41e6efd5c2746a655feb840525e5c (patch)
treebad2d686137a5a70b7ccd111f67d4986448c975c /drivers/media/video/em28xx/em28xx-input.c
parentf0bdee26a2dc904c463bae1c2ae9ad06f97f100d (diff)
V4L/DVB: ir-core: convert em28xx to not use ir-functions.c
Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-input.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c65
1 files changed, 16 insertions, 49 deletions
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 {
65struct em28xx_IR { 65struct em28xx_IR {
66 struct em28xx *dev; 66 struct em28xx *dev;
67 struct input_dev *input; 67 struct input_dev *input;
68 struct ir_input_state ir;
69 char name[32]; 68 char name[32];
70 char phys[32]; 69 char phys[32];
71 70
72 /* poll external decoder */ 71 /* poll external decoder */
73 int polling; 72 int polling;
74 struct delayed_work work; 73 struct delayed_work work;
75 unsigned int last_toggle:1;
76 unsigned int full_code:1; 74 unsigned int full_code:1;
77 unsigned int last_readcount; 75 unsigned int last_readcount;
78 unsigned int repeat_interval;
79 76
80 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); 77 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
81 78
@@ -291,7 +288,6 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
291static void em28xx_ir_handle_key(struct em28xx_IR *ir) 288static void em28xx_ir_handle_key(struct em28xx_IR *ir)
292{ 289{
293 int result; 290 int result;
294 int do_sendkey = 0;
295 struct em28xx_ir_poll_result poll_result; 291 struct em28xx_ir_poll_result poll_result;
296 292
297 /* read the registers containing the IR status */ 293 /* read the registers containing the IR status */
@@ -306,52 +302,28 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
306 ir->last_readcount, poll_result.rc_address, 302 ir->last_readcount, poll_result.rc_address,
307 poll_result.rc_data[0]); 303 poll_result.rc_data[0]);
308 304
309 if (ir->dev->chip_id == CHIP_ID_EM2874) { 305 if (poll_result.read_count > 0 &&
306 poll_result.read_count != ir->last_readcount) {
307 if (ir->full_code)
308 ir_keydown(ir->input,
309 poll_result.rc_address << 8 |
310 poll_result.rc_data[0],
311 poll_result.toggle_bit);
312 else
313 ir_keydown(ir->input,
314 poll_result.rc_data[0],
315 poll_result.toggle_bit);
316 }
317
318 if (ir->dev->chip_id == CHIP_ID_EM2874)
310 /* The em2874 clears the readcount field every time the 319 /* The em2874 clears the readcount field every time the
311 register is read. The em2860/2880 datasheet says that it 320 register is read. The em2860/2880 datasheet says that it
312 is supposed to clear the readcount, but it doesn't. So with 321 is supposed to clear the readcount, but it doesn't. So with
313 the em2874, we are looking for a non-zero read count as 322 the em2874, we are looking for a non-zero read count as
314 opposed to a readcount that is incrementing */ 323 opposed to a readcount that is incrementing */
315 ir->last_readcount = 0; 324 ir->last_readcount = 0;
316 } 325 else
317 326 ir->last_readcount = poll_result.read_count;
318 if (poll_result.read_count == 0) {
319 /* The button has not been pressed since the last read */
320 } else if (ir->last_toggle != poll_result.toggle_bit) {
321 /* A button has been pressed */
322 dprintk("button has been pressed\n");
323 ir->last_toggle = poll_result.toggle_bit;
324 ir->repeat_interval = 0;
325 do_sendkey = 1;
326 } else if (poll_result.toggle_bit == ir->last_toggle &&
327 poll_result.read_count > 0 &&
328 poll_result.read_count != ir->last_readcount) {
329 /* The button is still being held down */
330 dprintk("button being held down\n");
331
332 /* Debouncer for first keypress */
333 if (ir->repeat_interval++ > 9) {
334 /* Start repeating after 1 second */
335 do_sendkey = 1;
336 }
337 }
338
339 if (do_sendkey) {
340 dprintk("sending keypress\n");
341
342 if (ir->full_code)
343 ir_input_keydown(ir->input, &ir->ir,
344 poll_result.rc_address << 8 |
345 poll_result.rc_data[0]);
346 else
347 ir_input_keydown(ir->input, &ir->ir,
348 poll_result.rc_data[0]);
349
350 ir_input_nokey(ir->input, &ir->ir);
351 }
352
353 ir->last_readcount = poll_result.read_count;
354 return;
355} 327}
356 328
357static void em28xx_ir_work(struct work_struct *work) 329static void em28xx_ir_work(struct work_struct *work)
@@ -466,11 +438,6 @@ int em28xx_ir_init(struct em28xx *dev)
466 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 438 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
467 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 439 strlcat(ir->phys, "/input0", sizeof(ir->phys));
468 440
469 /* Set IR protocol */
470 err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER);
471 if (err < 0)
472 goto err_out_free;
473
474 input_dev->name = ir->name; 441 input_dev->name = ir->name;
475 input_dev->phys = ir->phys; 442 input_dev->phys = ir->phys;
476 input_dev->id.bustype = BUS_USB; 443 input_dev->id.bustype = BUS_USB;