diff options
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_input.c')
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_input.c | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c new file mode 100644 index 00000000000..db6d54d3fec --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_input.c | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | /* | ||
| 2 | Mantis PCI bridge driver | ||
| 3 | |||
| 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <media/rc-core.h> | ||
| 22 | #include <linux/pci.h> | ||
| 23 | |||
| 24 | #include "dmxdev.h" | ||
| 25 | #include "dvbdev.h" | ||
| 26 | #include "dvb_demux.h" | ||
| 27 | #include "dvb_frontend.h" | ||
| 28 | #include "dvb_net.h" | ||
| 29 | |||
| 30 | #include "mantis_common.h" | ||
| 31 | #include "mantis_reg.h" | ||
| 32 | #include "mantis_uart.h" | ||
| 33 | |||
| 34 | #define MODULE_NAME "mantis_core" | ||
| 35 | #define RC_MAP_MANTIS "rc-mantis" | ||
| 36 | |||
| 37 | static struct rc_map_table mantis_ir_table[] = { | ||
| 38 | { 0x29, KEY_POWER }, | ||
| 39 | { 0x28, KEY_FAVORITES }, | ||
| 40 | { 0x30, KEY_TEXT }, | ||
| 41 | { 0x17, KEY_INFO }, /* Preview */ | ||
| 42 | { 0x23, KEY_EPG }, | ||
| 43 | { 0x3b, KEY_F22 }, /* Record List */ | ||
| 44 | { 0x3c, KEY_1 }, | ||
| 45 | { 0x3e, KEY_2 }, | ||
| 46 | { 0x39, KEY_3 }, | ||
| 47 | { 0x36, KEY_4 }, | ||
| 48 | { 0x22, KEY_5 }, | ||
| 49 | { 0x20, KEY_6 }, | ||
| 50 | { 0x32, KEY_7 }, | ||
| 51 | { 0x26, KEY_8 }, | ||
| 52 | { 0x24, KEY_9 }, | ||
| 53 | { 0x2a, KEY_0 }, | ||
| 54 | |||
| 55 | { 0x33, KEY_CANCEL }, | ||
| 56 | { 0x2c, KEY_BACK }, | ||
| 57 | { 0x15, KEY_CLEAR }, | ||
| 58 | { 0x3f, KEY_TAB }, | ||
| 59 | { 0x10, KEY_ENTER }, | ||
| 60 | { 0x14, KEY_UP }, | ||
| 61 | { 0x0d, KEY_RIGHT }, | ||
| 62 | { 0x0e, KEY_DOWN }, | ||
| 63 | { 0x11, KEY_LEFT }, | ||
| 64 | |||
| 65 | { 0x21, KEY_VOLUMEUP }, | ||
| 66 | { 0x35, KEY_VOLUMEDOWN }, | ||
| 67 | { 0x3d, KEY_CHANNELDOWN }, | ||
| 68 | { 0x3a, KEY_CHANNELUP }, | ||
| 69 | { 0x2e, KEY_RECORD }, | ||
| 70 | { 0x2b, KEY_PLAY }, | ||
| 71 | { 0x13, KEY_PAUSE }, | ||
| 72 | { 0x25, KEY_STOP }, | ||
| 73 | |||
| 74 | { 0x1f, KEY_REWIND }, | ||
| 75 | { 0x2d, KEY_FASTFORWARD }, | ||
| 76 | { 0x1e, KEY_PREVIOUS }, /* Replay |< */ | ||
| 77 | { 0x1d, KEY_NEXT }, /* Skip >| */ | ||
| 78 | |||
| 79 | { 0x0b, KEY_CAMERA }, /* Capture */ | ||
| 80 | { 0x0f, KEY_LANGUAGE }, /* SAP */ | ||
| 81 | { 0x18, KEY_MODE }, /* PIP */ | ||
| 82 | { 0x12, KEY_ZOOM }, /* Full screen */ | ||
| 83 | { 0x1c, KEY_SUBTITLE }, | ||
| 84 | { 0x2f, KEY_MUTE }, | ||
| 85 | { 0x16, KEY_F20 }, /* L/R */ | ||
| 86 | { 0x38, KEY_F21 }, /* Hibernate */ | ||
| 87 | |||
| 88 | { 0x37, KEY_SWITCHVIDEOMODE }, /* A/V */ | ||
| 89 | { 0x31, KEY_AGAIN }, /* Recall */ | ||
| 90 | { 0x1a, KEY_KPPLUS }, /* Zoom+ */ | ||
| 91 | { 0x19, KEY_KPMINUS }, /* Zoom- */ | ||
| 92 | { 0x27, KEY_RED }, | ||
| 93 | { 0x0C, KEY_GREEN }, | ||
| 94 | { 0x01, KEY_YELLOW }, | ||
| 95 | { 0x00, KEY_BLUE }, | ||
| 96 | }; | ||
| 97 | |||
| 98 | static struct rc_map_list ir_mantis_map = { | ||
| 99 | .map = { | ||
| 100 | .scan = mantis_ir_table, | ||
| 101 | .size = ARRAY_SIZE(mantis_ir_table), | ||
| 102 | .rc_type = RC_TYPE_UNKNOWN, | ||
| 103 | .name = RC_MAP_MANTIS, | ||
| 104 | } | ||
| 105 | }; | ||
| 106 | |||
| 107 | int mantis_input_init(struct mantis_pci *mantis) | ||
| 108 | { | ||
| 109 | struct rc_dev *dev; | ||
| 110 | int err; | ||
| 111 | |||
| 112 | err = rc_map_register(&ir_mantis_map); | ||
| 113 | if (err) | ||
| 114 | goto out; | ||
| 115 | |||
| 116 | dev = rc_allocate_device(); | ||
| 117 | if (!dev) { | ||
| 118 | dprintk(MANTIS_ERROR, 1, "Remote device allocation failed"); | ||
| 119 | err = -ENOMEM; | ||
| 120 | goto out_map; | ||
| 121 | } | ||
| 122 | |||
| 123 | sprintf(mantis->input_name, "Mantis %s IR receiver", mantis->hwconfig->model_name); | ||
| 124 | sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev)); | ||
| 125 | |||
| 126 | dev->input_name = mantis->input_name; | ||
| 127 | dev->input_phys = mantis->input_phys; | ||
| 128 | dev->input_id.bustype = BUS_PCI; | ||
| 129 | dev->input_id.vendor = mantis->vendor_id; | ||
| 130 | dev->input_id.product = mantis->device_id; | ||
| 131 | dev->input_id.version = 1; | ||
| 132 | dev->driver_name = MODULE_NAME; | ||
| 133 | dev->map_name = RC_MAP_MANTIS; | ||
| 134 | dev->dev.parent = &mantis->pdev->dev; | ||
| 135 | |||
| 136 | err = rc_register_device(dev); | ||
| 137 | if (err) { | ||
| 138 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); | ||
| 139 | goto out_dev; | ||
| 140 | } | ||
| 141 | |||
| 142 | mantis->rc = dev; | ||
| 143 | return 0; | ||
| 144 | |||
| 145 | out_dev: | ||
| 146 | rc_free_device(dev); | ||
| 147 | out_map: | ||
| 148 | rc_map_unregister(&ir_mantis_map); | ||
| 149 | out: | ||
| 150 | return err; | ||
| 151 | } | ||
| 152 | |||
| 153 | int mantis_exit(struct mantis_pci *mantis) | ||
| 154 | { | ||
| 155 | rc_unregister_device(mantis->rc); | ||
| 156 | rc_map_unregister(&ir_mantis_map); | ||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
