mantis_input.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. */
  13. #include <media/rc-core.h>
  14. #include <linux/pci.h>
  15. #include "dmxdev.h"
  16. #include "dvbdev.h"
  17. #include "dvb_demux.h"
  18. #include "dvb_frontend.h"
  19. #include "dvb_net.h"
  20. #include "mantis_common.h"
  21. #include "mantis_input.h"
  22. #define MODULE_NAME "mantis_core"
  23. void mantis_input_process(struct mantis_pci *mantis, int scancode)
  24. {
  25. if (mantis->rc)
  26. rc_keydown(mantis->rc, RC_TYPE_UNKNOWN, scancode, 0);
  27. }
  28. int mantis_input_init(struct mantis_pci *mantis)
  29. {
  30. struct rc_dev *dev;
  31. int err;
  32. dev = rc_allocate_device();
  33. if (!dev) {
  34. dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
  35. err = -ENOMEM;
  36. goto out;
  37. }
  38. snprintf(mantis->input_name, sizeof(mantis->input_name),
  39. "Mantis %s IR receiver", mantis->hwconfig->model_name);
  40. snprintf(mantis->input_phys, sizeof(mantis->input_phys),
  41. "pci-%s/ir0", pci_name(mantis->pdev));
  42. dev->input_name = mantis->input_name;
  43. dev->input_phys = mantis->input_phys;
  44. dev->input_id.bustype = BUS_PCI;
  45. dev->input_id.vendor = mantis->vendor_id;
  46. dev->input_id.product = mantis->device_id;
  47. dev->input_id.version = 1;
  48. dev->driver_name = MODULE_NAME;
  49. dev->map_name = mantis->rc_map_name ? : RC_MAP_EMPTY;
  50. dev->dev.parent = &mantis->pdev->dev;
  51. err = rc_register_device(dev);
  52. if (err) {
  53. dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
  54. goto out_dev;
  55. }
  56. mantis->rc = dev;
  57. return 0;
  58. out_dev:
  59. rc_free_device(dev);
  60. out:
  61. return err;
  62. }
  63. EXPORT_SYMBOL_GPL(mantis_input_init);
  64. void mantis_input_exit(struct mantis_pci *mantis)
  65. {
  66. rc_unregister_device(mantis->rc);
  67. }
  68. EXPORT_SYMBOL_GPL(mantis_input_exit);