mantis_input.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 <media/rc-core.h>
  17. #include <linux/pci.h>
  18. #include "dmxdev.h"
  19. #include "dvbdev.h"
  20. #include "dvb_demux.h"
  21. #include "dvb_frontend.h"
  22. #include "dvb_net.h"
  23. #include "mantis_common.h"
  24. #include "mantis_reg.h"
  25. #include "mantis_uart.h"
  26. #define MODULE_NAME "mantis_core"
  27. #define RC_MAP_MANTIS "rc-mantis"
  28. static struct rc_map_table 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. static struct rc_map_list ir_mantis_map = {
  84. .map = {
  85. .scan = mantis_ir_table,
  86. .size = ARRAY_SIZE(mantis_ir_table),
  87. .rc_type = RC_TYPE_UNKNOWN,
  88. .name = RC_MAP_MANTIS,
  89. }
  90. };
  91. int mantis_input_init(struct mantis_pci *mantis)
  92. {
  93. struct rc_dev *dev;
  94. int err;
  95. err = rc_map_register(&ir_mantis_map);
  96. if (err)
  97. goto out;
  98. dev = rc_allocate_device();
  99. if (!dev) {
  100. dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
  101. err = -ENOMEM;
  102. goto out_map;
  103. }
  104. sprintf(mantis->input_name, "Mantis %s IR receiver", mantis->hwconfig->model_name);
  105. sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev));
  106. dev->input_name = mantis->input_name;
  107. dev->input_phys = mantis->input_phys;
  108. dev->input_id.bustype = BUS_PCI;
  109. dev->input_id.vendor = mantis->vendor_id;
  110. dev->input_id.product = mantis->device_id;
  111. dev->input_id.version = 1;
  112. dev->driver_name = MODULE_NAME;
  113. dev->map_name = RC_MAP_MANTIS;
  114. dev->dev.parent = &mantis->pdev->dev;
  115. err = rc_register_device(dev);
  116. if (err) {
  117. dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
  118. goto out_dev;
  119. }
  120. mantis->rc = dev;
  121. return 0;
  122. out_dev:
  123. rc_free_device(dev);
  124. out_map:
  125. rc_map_unregister(&ir_mantis_map);
  126. out:
  127. return err;
  128. }
  129. int mantis_exit(struct mantis_pci *mantis)
  130. {
  131. rc_unregister_device(mantis->rc);
  132. rc_map_unregister(&ir_mantis_map);
  133. return 0;
  134. }