mantis_input.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <linux/input.h>
  17. #include <media/ir-core.h>
  18. #include <linux/pci.h>
  19. #include "dmxdev.h"
  20. #include "dvbdev.h"
  21. #include "dvb_demux.h"
  22. #include "dvb_frontend.h"
  23. #include "dvb_net.h"
  24. #include "mantis_common.h"
  25. #include "mantis_reg.h"
  26. #include "mantis_uart.h"
  27. #define MODULE_NAME "mantis_core"
  28. static struct ir_scancode mantis_ir_table[] = {
  29. { 0x29, KEY_POWER },
  30. { 0x28, KEY_FAVORITES },
  31. { 0x30, KEY_TEXT },
  32. { 0x17, KEY_INFO }, /* Preview */
  33. { 0x23, KEY_EPG },
  34. { 0x3b, KEY_F22 }, /* Record List */
  35. { 0x3c, KEY_1 },
  36. { 0x3e, KEY_2 },
  37. { 0x39, KEY_3 },
  38. { 0x36, KEY_4 },
  39. { 0x22, KEY_5 },
  40. { 0x20, KEY_6 },
  41. { 0x32, KEY_7 },
  42. { 0x26, KEY_8 },
  43. { 0x24, KEY_9 },
  44. { 0x2a, KEY_0 },
  45. { 0x33, KEY_CANCEL },
  46. { 0x2c, KEY_BACK },
  47. { 0x15, KEY_CLEAR },
  48. { 0x3f, KEY_TAB },
  49. { 0x10, KEY_ENTER },
  50. { 0x14, KEY_UP },
  51. { 0x0d, KEY_RIGHT },
  52. { 0x0e, KEY_DOWN },
  53. { 0x11, KEY_LEFT },
  54. { 0x21, KEY_VOLUMEUP },
  55. { 0x35, KEY_VOLUMEDOWN },
  56. { 0x3d, KEY_CHANNELDOWN },
  57. { 0x3a, KEY_CHANNELUP },
  58. { 0x2e, KEY_RECORD },
  59. { 0x2b, KEY_PLAY },
  60. { 0x13, KEY_PAUSE },
  61. { 0x25, KEY_STOP },
  62. { 0x1f, KEY_REWIND },
  63. { 0x2d, KEY_FASTFORWARD },
  64. { 0x1e, KEY_PREVIOUS }, /* Replay |< */
  65. { 0x1d, KEY_NEXT }, /* Skip >| */
  66. { 0x0b, KEY_CAMERA }, /* Capture */
  67. { 0x0f, KEY_LANGUAGE }, /* SAP */
  68. { 0x18, KEY_MODE }, /* PIP */
  69. { 0x12, KEY_ZOOM }, /* Full screen */
  70. { 0x1c, KEY_SUBTITLE },
  71. { 0x2f, KEY_MUTE },
  72. { 0x16, KEY_F20 }, /* L/R */
  73. { 0x38, KEY_F21 }, /* Hibernate */
  74. { 0x37, KEY_SWITCHVIDEOMODE }, /* A/V */
  75. { 0x31, KEY_AGAIN }, /* Recall */
  76. { 0x1a, KEY_KPPLUS }, /* Zoom+ */
  77. { 0x19, KEY_KPMINUS }, /* Zoom- */
  78. { 0x27, KEY_RED },
  79. { 0x0C, KEY_GREEN },
  80. { 0x01, KEY_YELLOW },
  81. { 0x00, KEY_BLUE },
  82. };
  83. struct ir_scancode_table ir_mantis = {
  84. .scan = mantis_ir_table,
  85. .size = ARRAY_SIZE(mantis_ir_table),
  86. };
  87. EXPORT_SYMBOL_GPL(ir_mantis);
  88. int mantis_input_init(struct mantis_pci *mantis)
  89. {
  90. struct input_dev *rc;
  91. char name[80], dev[80];
  92. int err;
  93. rc = input_allocate_device();
  94. if (!rc) {
  95. dprintk(MANTIS_ERROR, 1, "Input device allocate failed");
  96. return -ENOMEM;
  97. }
  98. sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name);
  99. sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev));
  100. rc->name = name;
  101. rc->phys = dev;
  102. rc->id.bustype = BUS_PCI;
  103. rc->id.vendor = mantis->vendor_id;
  104. rc->id.product = mantis->device_id;
  105. rc->id.version = 1;
  106. rc->dev = mantis->pdev->dev;
  107. err = __ir_input_register(rc, &ir_mantis, NULL, MODULE_NAME);
  108. if (err) {
  109. dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
  110. input_free_device(rc);
  111. return -ENODEV;
  112. }
  113. mantis->rc = rc;
  114. return 0;
  115. }
  116. int mantis_exit(struct mantis_pci *mantis)
  117. {
  118. struct input_dev *rc = mantis->rc;
  119. ir_input_unregister(rc);
  120. return 0;
  121. }