aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:53 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:53 -0400
commitb7df3910c1298fee8ed7b9dfd2da74b85df5539c (patch)
tree1948ee697c23a384dd0be625ebeee13062d73882 /drivers/media/video/cx88
parent76b7cddfd576331761e945a508254abad11039e9 (diff)
[PATCH] drivers/media: convert to dynamic input_dev allocation
Input: convert drivers/media to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r--drivers/media/video/cx88/cx88-input.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index d81b21d6e05d..c27fe4c36f69 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -260,7 +260,7 @@ static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = {
260 260
261struct cx88_IR { 261struct cx88_IR {
262 struct cx88_core *core; 262 struct cx88_core *core;
263 struct input_dev input; 263 struct input_dev *input;
264 struct ir_input_state ir; 264 struct ir_input_state ir;
265 char name[32]; 265 char name[32];
266 char phys[32]; 266 char phys[32];
@@ -315,23 +315,23 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
315 if (ir->mask_keydown) { 315 if (ir->mask_keydown) {
316 /* bit set on keydown */ 316 /* bit set on keydown */
317 if (gpio & ir->mask_keydown) { 317 if (gpio & ir->mask_keydown) {
318 ir_input_keydown(&ir->input, &ir->ir, data, data); 318 ir_input_keydown(ir->input, &ir->ir, data, data);
319 } else { 319 } else {
320 ir_input_nokey(&ir->input, &ir->ir); 320 ir_input_nokey(ir->input, &ir->ir);
321 } 321 }
322 322
323 } else if (ir->mask_keyup) { 323 } else if (ir->mask_keyup) {
324 /* bit cleared on keydown */ 324 /* bit cleared on keydown */
325 if (0 == (gpio & ir->mask_keyup)) { 325 if (0 == (gpio & ir->mask_keyup)) {
326 ir_input_keydown(&ir->input, &ir->ir, data, data); 326 ir_input_keydown(ir->input, &ir->ir, data, data);
327 } else { 327 } else {
328 ir_input_nokey(&ir->input, &ir->ir); 328 ir_input_nokey(ir->input, &ir->ir);
329 } 329 }
330 330
331 } else { 331 } else {
332 /* can't distinguish keydown/up :-/ */ 332 /* can't distinguish keydown/up :-/ */
333 ir_input_keydown(&ir->input, &ir->ir, data, data); 333 ir_input_keydown(ir->input, &ir->ir, data, data);
334 ir_input_nokey(&ir->input, &ir->ir); 334 ir_input_nokey(ir->input, &ir->ir);
335 } 335 }
336} 336}
337 337
@@ -357,13 +357,19 @@ static void cx88_ir_work(void *data)
357int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) 357int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
358{ 358{
359 struct cx88_IR *ir; 359 struct cx88_IR *ir;
360 struct input_dev *input_dev;
360 IR_KEYTAB_TYPE *ir_codes = NULL; 361 IR_KEYTAB_TYPE *ir_codes = NULL;
361 int ir_type = IR_TYPE_OTHER; 362 int ir_type = IR_TYPE_OTHER;
362 363
363 ir = kmalloc(sizeof(*ir), GFP_KERNEL); 364 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
364 if (NULL == ir) 365 input_dev = input_allocate_device();
366 if (!ir || !input_dev) {
367 kfree(ir);
368 input_free_device(input_dev);
365 return -ENOMEM; 369 return -ENOMEM;
366 memset(ir, 0, sizeof(*ir)); 370 }
371
372 ir->input = input_dev;
367 373
368 /* detect & configure */ 374 /* detect & configure */
369 switch (core->board) { 375 switch (core->board) {
@@ -425,6 +431,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
425 431
426 if (NULL == ir_codes) { 432 if (NULL == ir_codes) {
427 kfree(ir); 433 kfree(ir);
434 input_free_device(input_dev);
428 return -ENODEV; 435 return -ENODEV;
429 } 436 }
430 437
@@ -433,19 +440,19 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
433 cx88_boards[core->board].name); 440 cx88_boards[core->board].name);
434 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 441 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
435 442
436 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 443 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
437 ir->input.name = ir->name; 444 input_dev->name = ir->name;
438 ir->input.phys = ir->phys; 445 input_dev->phys = ir->phys;
439 ir->input.id.bustype = BUS_PCI; 446 input_dev->id.bustype = BUS_PCI;
440 ir->input.id.version = 1; 447 input_dev->id.version = 1;
441 if (pci->subsystem_vendor) { 448 if (pci->subsystem_vendor) {
442 ir->input.id.vendor = pci->subsystem_vendor; 449 input_dev->id.vendor = pci->subsystem_vendor;
443 ir->input.id.product = pci->subsystem_device; 450 input_dev->id.product = pci->subsystem_device;
444 } else { 451 } else {
445 ir->input.id.vendor = pci->vendor; 452 input_dev->id.vendor = pci->vendor;
446 ir->input.id.product = pci->device; 453 input_dev->id.product = pci->device;
447 } 454 }
448 ir->input.dev = &pci->dev; 455 input_dev->cdev.dev = &pci->dev;
449 456
450 /* record handles to ourself */ 457 /* record handles to ourself */
451 ir->core = core; 458 ir->core = core;
@@ -465,8 +472,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
465 } 472 }
466 473
467 /* all done */ 474 /* all done */
468 input_register_device(&ir->input); 475 input_register_device(ir->input);
469 printk("%s: registered IR remote control\n", core->name);
470 476
471 return 0; 477 return 0;
472} 478}
@@ -484,7 +490,7 @@ int cx88_ir_fini(struct cx88_core *core)
484 flush_scheduled_work(); 490 flush_scheduled_work();
485 } 491 }
486 492
487 input_unregister_device(&ir->input); 493 input_unregister_device(ir->input);
488 kfree(ir); 494 kfree(ir);
489 495
490 /* done */ 496 /* done */
@@ -515,7 +521,7 @@ void cx88_ir_irq(struct cx88_core *core)
515 if (!ir->scount) { 521 if (!ir->scount) {
516 /* nothing to sample */ 522 /* nothing to sample */
517 if (ir->ir.keypressed && time_after(jiffies, ir->release)) 523 if (ir->ir.keypressed && time_after(jiffies, ir->release))
518 ir_input_nokey(&ir->input, &ir->ir); 524 ir_input_nokey(ir->input, &ir->ir);
519 return; 525 return;
520 } 526 }
521 527
@@ -557,7 +563,7 @@ void cx88_ir_irq(struct cx88_core *core)
557 563
558 ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); 564 ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f);
559 565
560 ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); 566 ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff);
561 ir->release = jiffies + msecs_to_jiffies(120); 567 ir->release = jiffies + msecs_to_jiffies(120);
562 break; 568 break;
563 case CX88_BOARD_HAUPPAUGE: 569 case CX88_BOARD_HAUPPAUGE:
@@ -566,7 +572,7 @@ void cx88_ir_irq(struct cx88_core *core)
566 ir_dprintk("biphase decoded: %x\n", ircode); 572 ir_dprintk("biphase decoded: %x\n", ircode);
567 if ((ircode & 0xfffff000) != 0x3000) 573 if ((ircode & 0xfffff000) != 0x3000)
568 break; 574 break;
569 ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); 575 ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode);
570 ir->release = jiffies + msecs_to_jiffies(120); 576 ir->release = jiffies + msecs_to_jiffies(120);
571 break; 577 break;
572 } 578 }