Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Device driver for GPIO attached remote control interfaces |
| 4 | * on Conexant 2388x based TV/DVB cards. |
| 5 | * |
| 6 | * Copyright (c) 2003 Pavel Machek |
| 7 | * Copyright (c) 2004 Gerd Knorr |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 8 | * Copyright (c) 2004, 2005 Chris Pascoe |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/input.h> |
| 28 | #include <linux/pci.h> |
| 29 | #include <linux/module.h> |
| 30 | #include <linux/moduleparam.h> |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "cx88.h" |
Mauro Carvalho Chehab | d21838d | 2006-01-09 15:25:21 -0200 | [diff] [blame] | 33 | #include <media/ir-common.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* ---------------------------------------------------------------------- */ |
| 36 | |
| 37 | /* DigitalNow DNTV Live DVB-T Remote */ |
| 38 | static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 39 | [0x00] = KEY_ESC, /* 'go up a level?' */ |
| 40 | /* Keys 0 to 9 */ |
| 41 | [0x0a] = KEY_KP0, |
| 42 | [0x01] = KEY_KP1, |
| 43 | [0x02] = KEY_KP2, |
| 44 | [0x03] = KEY_KP3, |
| 45 | [0x04] = KEY_KP4, |
| 46 | [0x05] = KEY_KP5, |
| 47 | [0x06] = KEY_KP6, |
| 48 | [0x07] = KEY_KP7, |
| 49 | [0x08] = KEY_KP8, |
| 50 | [0x09] = KEY_KP9, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 52 | [0x0b] = KEY_TUNER, /* tv/fm */ |
| 53 | [0x0c] = KEY_SEARCH, /* scan */ |
| 54 | [0x0d] = KEY_STOP, |
| 55 | [0x0e] = KEY_PAUSE, |
| 56 | [0x0f] = KEY_LIST, /* source */ |
| 57 | |
| 58 | [0x10] = KEY_MUTE, |
| 59 | [0x11] = KEY_REWIND, /* backward << */ |
| 60 | [0x12] = KEY_POWER, |
| 61 | [0x13] = KEY_S, /* snap */ |
| 62 | [0x14] = KEY_AUDIO, /* stereo */ |
| 63 | [0x15] = KEY_CLEAR, /* reset */ |
| 64 | [0x16] = KEY_PLAY, |
| 65 | [0x17] = KEY_ENTER, |
| 66 | [0x18] = KEY_ZOOM, /* full screen */ |
| 67 | [0x19] = KEY_FASTFORWARD, /* forward >> */ |
| 68 | [0x1a] = KEY_CHANNELUP, |
| 69 | [0x1b] = KEY_VOLUMEUP, |
| 70 | [0x1c] = KEY_INFO, /* preview */ |
| 71 | [0x1d] = KEY_RECORD, /* record */ |
| 72 | [0x1e] = KEY_CHANNELDOWN, |
| 73 | [0x1f] = KEY_VOLUMEDOWN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /* ---------------------------------------------------------------------- */ |
| 77 | |
| 78 | /* IO-DATA BCTV7E Remote */ |
| 79 | static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 80 | [0x40] = KEY_TV, |
| 81 | [0x20] = KEY_RADIO, /* FM */ |
| 82 | [0x60] = KEY_EPG, |
| 83 | [0x00] = KEY_POWER, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 85 | /* Keys 0 to 9 */ |
| 86 | [0x44] = KEY_KP0, /* 10 */ |
| 87 | [0x50] = KEY_KP1, |
| 88 | [0x30] = KEY_KP2, |
| 89 | [0x70] = KEY_KP3, |
| 90 | [0x48] = KEY_KP4, |
| 91 | [0x28] = KEY_KP5, |
| 92 | [0x68] = KEY_KP6, |
| 93 | [0x58] = KEY_KP7, |
| 94 | [0x38] = KEY_KP8, |
| 95 | [0x78] = KEY_KP9, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 97 | [0x10] = KEY_L, /* Live */ |
| 98 | [0x08] = KEY_T, /* Time Shift */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 100 | [0x18] = KEY_PLAYPAUSE, /* Play */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 102 | [0x24] = KEY_ENTER, /* 11 */ |
| 103 | [0x64] = KEY_ESC, /* 12 */ |
| 104 | [0x04] = KEY_M, /* Multi */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 106 | [0x54] = KEY_VIDEO, |
| 107 | [0x34] = KEY_CHANNELUP, |
| 108 | [0x74] = KEY_VOLUMEUP, |
| 109 | [0x14] = KEY_MUTE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 111 | [0x4c] = KEY_S, /* SVIDEO */ |
| 112 | [0x2c] = KEY_CHANNELDOWN, |
| 113 | [0x6c] = KEY_VOLUMEDOWN, |
| 114 | [0x0c] = KEY_ZOOM, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 116 | [0x5c] = KEY_PAUSE, |
| 117 | [0x3c] = KEY_C, /* || (red) */ |
| 118 | [0x7c] = KEY_RECORD, /* recording */ |
| 119 | [0x1c] = KEY_STOP, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 121 | [0x41] = KEY_REWIND, /* backward << */ |
| 122 | [0x21] = KEY_PLAY, |
| 123 | [0x61] = KEY_FASTFORWARD, /* forward >> */ |
| 124 | [0x01] = KEY_NEXT, /* skip >| */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | /* ---------------------------------------------------------------------- */ |
| 128 | |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 129 | /* ADS Tech Instant TV DVB-T PCI Remote */ |
| 130 | static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 131 | /* Keys 0 to 9 */ |
| 132 | [0x4d] = KEY_0, |
| 133 | [0x57] = KEY_1, |
| 134 | [0x4f] = KEY_2, |
| 135 | [0x53] = KEY_3, |
| 136 | [0x56] = KEY_4, |
| 137 | [0x4e] = KEY_5, |
| 138 | [0x5e] = KEY_6, |
| 139 | [0x54] = KEY_7, |
| 140 | [0x4c] = KEY_8, |
| 141 | [0x5c] = KEY_9, |
| 142 | |
| 143 | [0x5b] = KEY_POWER, |
| 144 | [0x5f] = KEY_MUTE, |
| 145 | [0x55] = KEY_GOTO, |
| 146 | [0x5d] = KEY_SEARCH, |
| 147 | [0x17] = KEY_EPG, /* Guide */ |
| 148 | [0x1f] = KEY_MENU, |
| 149 | [0x0f] = KEY_UP, |
| 150 | [0x46] = KEY_DOWN, |
| 151 | [0x16] = KEY_LEFT, |
| 152 | [0x1e] = KEY_RIGHT, |
| 153 | [0x0e] = KEY_SELECT, /* Enter */ |
| 154 | [0x5a] = KEY_INFO, |
| 155 | [0x52] = KEY_EXIT, |
| 156 | [0x59] = KEY_PREVIOUS, |
| 157 | [0x51] = KEY_NEXT, |
| 158 | [0x58] = KEY_REWIND, |
| 159 | [0x50] = KEY_FORWARD, |
| 160 | [0x44] = KEY_PLAYPAUSE, |
| 161 | [0x07] = KEY_STOP, |
| 162 | [0x1b] = KEY_RECORD, |
| 163 | [0x13] = KEY_TUNER, /* Live */ |
| 164 | [0x0a] = KEY_A, |
| 165 | [0x12] = KEY_B, |
| 166 | [0x03] = KEY_PROG1, /* 1 */ |
| 167 | [0x01] = KEY_PROG2, /* 2 */ |
| 168 | [0x00] = KEY_PROG3, /* 3 */ |
| 169 | [0x06] = KEY_DVD, |
| 170 | [0x48] = KEY_AUX, /* Photo */ |
| 171 | [0x40] = KEY_VIDEO, |
| 172 | [0x19] = KEY_AUDIO, /* Music */ |
| 173 | [0x0b] = KEY_CHANNELUP, |
| 174 | [0x08] = KEY_CHANNELDOWN, |
| 175 | [0x15] = KEY_VOLUMEUP, |
| 176 | [0x1c] = KEY_VOLUMEDOWN, |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | /* ---------------------------------------------------------------------- */ |
| 180 | |
| 181 | /* MSI TV@nywhere remote */ |
| 182 | static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 183 | /* Keys 0 to 9 */ |
| 184 | [0x00] = KEY_0, |
| 185 | [0x01] = KEY_1, |
| 186 | [0x02] = KEY_2, |
| 187 | [0x03] = KEY_3, |
| 188 | [0x04] = KEY_4, |
| 189 | [0x05] = KEY_5, |
| 190 | [0x06] = KEY_6, |
| 191 | [0x07] = KEY_7, |
| 192 | [0x08] = KEY_8, |
| 193 | [0x09] = KEY_9, |
| 194 | |
| 195 | [0x0c] = KEY_MUTE, |
| 196 | [0x0f] = KEY_SCREEN, /* Full Screen */ |
| 197 | [0x10] = KEY_F, /* Funtion */ |
| 198 | [0x11] = KEY_T, /* Time shift */ |
| 199 | [0x12] = KEY_POWER, |
| 200 | [0x13] = KEY_MEDIA, /* MTS */ |
| 201 | [0x14] = KEY_SLOW, |
| 202 | [0x16] = KEY_REWIND, /* backward << */ |
| 203 | [0x17] = KEY_ENTER, /* Return */ |
| 204 | [0x18] = KEY_FASTFORWARD, /* forward >> */ |
| 205 | [0x1a] = KEY_CHANNELUP, |
| 206 | [0x1b] = KEY_VOLUMEUP, |
| 207 | [0x1e] = KEY_CHANNELDOWN, |
| 208 | [0x1f] = KEY_VOLUMEDOWN, |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 209 | }; |
| 210 | |
| 211 | /* ---------------------------------------------------------------------- */ |
| 212 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 213 | /* Cinergy 1400 DVB-T */ |
| 214 | static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { |
| 215 | [0x01] = KEY_POWER, |
| 216 | [0x02] = KEY_1, |
| 217 | [0x03] = KEY_2, |
| 218 | [0x04] = KEY_3, |
| 219 | [0x05] = KEY_4, |
| 220 | [0x06] = KEY_5, |
| 221 | [0x07] = KEY_6, |
| 222 | [0x08] = KEY_7, |
| 223 | [0x09] = KEY_8, |
| 224 | [0x0a] = KEY_9, |
| 225 | [0x0c] = KEY_0, |
| 226 | |
| 227 | [0x0b] = KEY_VIDEO, |
| 228 | [0x0d] = KEY_REFRESH, |
| 229 | [0x0e] = KEY_SELECT, |
| 230 | [0x0f] = KEY_EPG, |
| 231 | [0x10] = KEY_UP, |
| 232 | [0x11] = KEY_LEFT, |
| 233 | [0x12] = KEY_OK, |
| 234 | [0x13] = KEY_RIGHT, |
| 235 | [0x14] = KEY_DOWN, |
| 236 | [0x15] = KEY_TEXT, |
| 237 | [0x16] = KEY_INFO, |
| 238 | |
| 239 | [0x17] = KEY_RED, |
| 240 | [0x18] = KEY_GREEN, |
| 241 | [0x19] = KEY_YELLOW, |
| 242 | [0x1a] = KEY_BLUE, |
| 243 | |
| 244 | [0x1b] = KEY_CHANNELUP, |
| 245 | [0x1c] = KEY_VOLUMEUP, |
| 246 | [0x1d] = KEY_MUTE, |
| 247 | [0x1e] = KEY_VOLUMEDOWN, |
| 248 | [0x1f] = KEY_CHANNELDOWN, |
| 249 | |
| 250 | [0x40] = KEY_PAUSE, |
| 251 | [0x4c] = KEY_PLAY, |
| 252 | [0x58] = KEY_RECORD, |
| 253 | [0x54] = KEY_PREVIOUS, |
| 254 | [0x48] = KEY_STOP, |
| 255 | [0x5c] = KEY_NEXT, |
| 256 | }; |
| 257 | |
| 258 | /* ---------------------------------------------------------------------- */ |
| 259 | |
George Gazurkoff | 899ad11 | 2006-01-09 15:25:19 -0200 | [diff] [blame] | 260 | /* AVERTV STUDIO 303 Remote */ |
| 261 | static IR_KEYTAB_TYPE ir_codes_avertv_303[IR_KEYTAB_SIZE] = { |
| 262 | [ 0x2a ] = KEY_KP1, |
| 263 | [ 0x32 ] = KEY_KP2, |
| 264 | [ 0x3a ] = KEY_KP3, |
| 265 | [ 0x4a ] = KEY_KP4, |
| 266 | [ 0x52 ] = KEY_KP5, |
| 267 | [ 0x5a ] = KEY_KP6, |
| 268 | [ 0x6a ] = KEY_KP7, |
| 269 | [ 0x72 ] = KEY_KP8, |
| 270 | [ 0x7a ] = KEY_KP9, |
| 271 | [ 0x0e ] = KEY_KP0, |
| 272 | |
| 273 | [ 0x02 ] = KEY_POWER, |
| 274 | [ 0x22 ] = KEY_VIDEO, |
| 275 | [ 0x42 ] = KEY_AUDIO, |
| 276 | [ 0x62 ] = KEY_ZOOM, |
| 277 | [ 0x0a ] = KEY_TV, |
| 278 | [ 0x12 ] = KEY_CD, |
| 279 | [ 0x1a ] = KEY_TEXT, |
| 280 | |
| 281 | [ 0x16 ] = KEY_SUBTITLE, |
| 282 | [ 0x1e ] = KEY_REWIND, |
| 283 | [ 0x06 ] = KEY_PRINT, |
| 284 | |
| 285 | [ 0x2e ] = KEY_SEARCH, |
| 286 | [ 0x36 ] = KEY_SLEEP, |
| 287 | [ 0x3e ] = KEY_SHUFFLE, |
| 288 | [ 0x26 ] = KEY_MUTE, |
| 289 | |
| 290 | [ 0x4e ] = KEY_RECORD, |
| 291 | [ 0x56 ] = KEY_PAUSE, |
| 292 | [ 0x5e ] = KEY_STOP, |
| 293 | [ 0x46 ] = KEY_PLAY, |
| 294 | |
| 295 | [ 0x6e ] = KEY_RED, |
| 296 | [ 0x0b ] = KEY_GREEN, |
| 297 | [ 0x66 ] = KEY_YELLOW, |
| 298 | [ 0x03 ] = KEY_BLUE, |
| 299 | |
| 300 | [ 0x76 ] = KEY_LEFT, |
| 301 | [ 0x7e ] = KEY_RIGHT, |
| 302 | [ 0x13 ] = KEY_DOWN, |
| 303 | [ 0x1b ] = KEY_UP, |
| 304 | }; |
| 305 | |
| 306 | /* ---------------------------------------------------------------------- */ |
| 307 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 308 | /* DigitalNow DNTV Live! DVB-T Pro Remote */ |
| 309 | static IR_KEYTAB_TYPE ir_codes_dntv_live_dvbt_pro[IR_KEYTAB_SIZE] = { |
| 310 | [ 0x16 ] = KEY_POWER, |
| 311 | [ 0x5b ] = KEY_HOME, |
| 312 | |
| 313 | [ 0x55 ] = KEY_TV, /* live tv */ |
| 314 | [ 0x58 ] = KEY_TUNER, /* digital Radio */ |
| 315 | [ 0x5a ] = KEY_RADIO, /* FM radio */ |
| 316 | [ 0x59 ] = KEY_DVD, /* dvd menu */ |
| 317 | [ 0x03 ] = KEY_1, |
| 318 | [ 0x01 ] = KEY_2, |
| 319 | [ 0x06 ] = KEY_3, |
| 320 | [ 0x09 ] = KEY_4, |
| 321 | [ 0x1d ] = KEY_5, |
| 322 | [ 0x1f ] = KEY_6, |
| 323 | [ 0x0d ] = KEY_7, |
| 324 | [ 0x19 ] = KEY_8, |
| 325 | [ 0x1b ] = KEY_9, |
| 326 | [ 0x0c ] = KEY_CANCEL, |
| 327 | [ 0x15 ] = KEY_0, |
| 328 | [ 0x4a ] = KEY_CLEAR, |
| 329 | [ 0x13 ] = KEY_BACK, |
| 330 | [ 0x00 ] = KEY_TAB, |
| 331 | [ 0x4b ] = KEY_UP, |
| 332 | [ 0x4e ] = KEY_LEFT, |
| 333 | [ 0x4f ] = KEY_OK, |
| 334 | [ 0x52 ] = KEY_RIGHT, |
| 335 | [ 0x51 ] = KEY_DOWN, |
| 336 | [ 0x1e ] = KEY_VOLUMEUP, |
| 337 | [ 0x0a ] = KEY_VOLUMEDOWN, |
| 338 | [ 0x02 ] = KEY_CHANNELDOWN, |
| 339 | [ 0x05 ] = KEY_CHANNELUP, |
| 340 | [ 0x11 ] = KEY_RECORD, |
| 341 | [ 0x14 ] = KEY_PLAY, |
| 342 | [ 0x4c ] = KEY_PAUSE, |
| 343 | [ 0x1a ] = KEY_STOP, |
| 344 | [ 0x40 ] = KEY_REWIND, |
| 345 | [ 0x12 ] = KEY_FASTFORWARD, |
| 346 | [ 0x41 ] = KEY_PREVIOUSSONG, /* replay |< */ |
| 347 | [ 0x42 ] = KEY_NEXTSONG, /* skip >| */ |
| 348 | [ 0x54 ] = KEY_CAMERA, /* capture */ |
| 349 | [ 0x50 ] = KEY_LANGUAGE, /* sap */ |
| 350 | [ 0x47 ] = KEY_TV2, /* pip */ |
| 351 | [ 0x4d ] = KEY_SCREEN, |
| 352 | [ 0x43 ] = KEY_SUBTITLE, |
| 353 | [ 0x10 ] = KEY_MUTE, |
| 354 | [ 0x49 ] = KEY_AUDIO, /* l/r */ |
| 355 | [ 0x07 ] = KEY_SLEEP, |
| 356 | [ 0x08 ] = KEY_VIDEO, /* a/v */ |
| 357 | [ 0x0e ] = KEY_PREVIOUS, /* recall */ |
| 358 | [ 0x45 ] = KEY_ZOOM, /* zoom + */ |
| 359 | [ 0x46 ] = KEY_ANGLE, /* zoom - */ |
| 360 | [ 0x56 ] = KEY_RED, |
| 361 | [ 0x57 ] = KEY_GREEN, |
| 362 | [ 0x5c ] = KEY_YELLOW, |
| 363 | [ 0x5d ] = KEY_BLUE, |
| 364 | }; |
| 365 | |
| 366 | /* ---------------------------------------------------------------------- */ |
| 367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | struct cx88_IR { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 369 | struct cx88_core *core; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 370 | struct input_dev *input; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 371 | struct ir_input_state ir; |
| 372 | char name[32]; |
| 373 | char phys[32]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
| 375 | /* sample from gpio pin 16 */ |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 376 | u32 sampling; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 377 | u32 samples[16]; |
| 378 | int scount; |
| 379 | unsigned long release; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
| 381 | /* poll external decoder */ |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 382 | int polling; |
| 383 | struct work_struct work; |
| 384 | struct timer_list timer; |
| 385 | u32 gpio_addr; |
| 386 | u32 last_gpio; |
| 387 | u32 mask_keycode; |
| 388 | u32 mask_keydown; |
| 389 | u32 mask_keyup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | static int ir_debug = 0; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 393 | module_param(ir_debug, int, 0644); /* debug level [IR] */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); |
| 395 | |
| 396 | #define ir_dprintk(fmt, arg...) if (ir_debug) \ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 397 | printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
| 399 | /* ---------------------------------------------------------------------- */ |
| 400 | |
| 401 | static void cx88_ir_handle_key(struct cx88_IR *ir) |
| 402 | { |
| 403 | struct cx88_core *core = ir->core; |
| 404 | u32 gpio, data; |
| 405 | |
| 406 | /* read gpio value */ |
| 407 | gpio = cx_read(ir->gpio_addr); |
| 408 | if (ir->polling) { |
| 409 | if (ir->last_gpio == gpio) |
| 410 | return; |
| 411 | ir->last_gpio = gpio; |
| 412 | } |
| 413 | |
| 414 | /* extract data */ |
| 415 | data = ir_extract_bits(gpio, ir->mask_keycode); |
| 416 | ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n", |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 417 | gpio, data, |
| 418 | ir->polling ? "poll" : "irq", |
| 419 | (gpio & ir->mask_keydown) ? " down" : "", |
| 420 | (gpio & ir->mask_keyup) ? " up" : ""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | if (ir->mask_keydown) { |
| 423 | /* bit set on keydown */ |
| 424 | if (gpio & ir->mask_keydown) { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 425 | ir_input_keydown(ir->input, &ir->ir, data, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | } else { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 427 | ir_input_nokey(ir->input, &ir->ir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | } else if (ir->mask_keyup) { |
| 431 | /* bit cleared on keydown */ |
| 432 | if (0 == (gpio & ir->mask_keyup)) { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 433 | ir_input_keydown(ir->input, &ir->ir, data, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | } else { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 435 | ir_input_nokey(ir->input, &ir->ir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | } else { |
| 439 | /* can't distinguish keydown/up :-/ */ |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 440 | ir_input_keydown(ir->input, &ir->ir, data, data); |
| 441 | ir_input_nokey(ir->input, &ir->ir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | |
| 445 | static void ir_timer(unsigned long data) |
| 446 | { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 447 | struct cx88_IR *ir = (struct cx88_IR *)data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
| 449 | schedule_work(&ir->work); |
| 450 | } |
| 451 | |
| 452 | static void cx88_ir_work(void *data) |
| 453 | { |
| 454 | struct cx88_IR *ir = data; |
| 455 | unsigned long timeout; |
| 456 | |
| 457 | cx88_ir_handle_key(ir); |
| 458 | timeout = jiffies + (ir->polling * HZ / 1000); |
| 459 | mod_timer(&ir->timer, timeout); |
| 460 | } |
| 461 | |
| 462 | /* ---------------------------------------------------------------------- */ |
| 463 | |
| 464 | int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) |
| 465 | { |
| 466 | struct cx88_IR *ir; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 467 | struct input_dev *input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | IR_KEYTAB_TYPE *ir_codes = NULL; |
| 469 | int ir_type = IR_TYPE_OTHER; |
| 470 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 471 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
| 472 | input_dev = input_allocate_device(); |
| 473 | if (!ir || !input_dev) { |
| 474 | kfree(ir); |
| 475 | input_free_device(input_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | return -ENOMEM; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | ir->input = input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
| 481 | /* detect & configure */ |
| 482 | switch (core->board) { |
| 483 | case CX88_BOARD_DNTV_LIVE_DVB_T: |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 484 | case CX88_BOARD_KWORLD_DVB_T: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 485 | ir_codes = ir_codes_dntv_live_dvb_t; |
| 486 | ir->gpio_addr = MO_GP1_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | ir->mask_keycode = 0x1f; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 488 | ir->mask_keyup = 0x60; |
| 489 | ir->polling = 50; /* ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 491 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
| 492 | ir_codes = ir_codes_cinergy_1400; |
| 493 | ir_type = IR_TYPE_PD; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 494 | ir->sampling = 0xeb04; /* address */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 495 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | case CX88_BOARD_HAUPPAUGE: |
| 497 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
Steven Toth | fb56cb6 | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 498 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
| 499 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 500 | case CX88_BOARD_HAUPPAUGE_HVR1100: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 501 | ir_codes = ir_codes_hauppauge_new; |
| 502 | ir_type = IR_TYPE_RC5; |
| 503 | ir->sampling = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | break; |
| 505 | case CX88_BOARD_WINFAST2000XP_EXPERT: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 506 | ir_codes = ir_codes_winfast; |
| 507 | ir->gpio_addr = MO_GP0_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | ir->mask_keycode = 0x8f8; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 509 | ir->mask_keyup = 0x100; |
| 510 | ir->polling = 1; /* ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | break; |
| 512 | case CX88_BOARD_IODATA_GVBCTV7E: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 513 | ir_codes = ir_codes_iodata_bctv7e; |
| 514 | ir->gpio_addr = MO_GP0_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | ir->mask_keycode = 0xfd; |
| 516 | ir->mask_keydown = 0x02; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 517 | ir->polling = 5; /* ms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | break; |
Manuel Capinha | 239df2e | 2005-06-23 22:04:53 -0700 | [diff] [blame] | 519 | case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 520 | ir_codes = ir_codes_pixelview; |
| 521 | ir->gpio_addr = MO_GP1_IO; |
Manuel Capinha | 239df2e | 2005-06-23 22:04:53 -0700 | [diff] [blame] | 522 | ir->mask_keycode = 0x1f; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 523 | ir->mask_keyup = 0x80; |
| 524 | ir->polling = 1; /* ms */ |
Manuel Capinha | 239df2e | 2005-06-23 22:04:53 -0700 | [diff] [blame] | 525 | break; |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 526 | case CX88_BOARD_ADSTECH_DVB_T_PCI: |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 527 | ir_codes = ir_codes_adstech_dvb_t_pci; |
| 528 | ir->gpio_addr = MO_GP1_IO; |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 529 | ir->mask_keycode = 0xbf; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 530 | ir->mask_keyup = 0x40; |
| 531 | ir->polling = 50; /* ms */ |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 532 | break; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 533 | case CX88_BOARD_MSI_TVANYWHERE_MASTER: |
| 534 | ir_codes = ir_codes_msi_tvanywhere; |
| 535 | ir->gpio_addr = MO_GP1_IO; |
| 536 | ir->mask_keycode = 0x1f; |
| 537 | ir->mask_keyup = 0x40; |
| 538 | ir->polling = 1; /* ms */ |
| 539 | break; |
George Gazurkoff | 899ad11 | 2006-01-09 15:25:19 -0200 | [diff] [blame] | 540 | case CX88_BOARD_AVERTV_303: |
George Gazurkoff | 565f494 | 2006-01-09 15:32:46 -0200 | [diff] [blame^] | 541 | case CX88_BOARD_AVERTV_STUDIO_303: |
George Gazurkoff | 899ad11 | 2006-01-09 15:25:19 -0200 | [diff] [blame] | 542 | ir_codes = ir_codes_avertv_303; |
| 543 | ir->gpio_addr = MO_GP2_IO; |
| 544 | ir->mask_keycode = 0xfb; |
| 545 | ir->mask_keydown = 0x02; |
| 546 | ir->polling = 50; /* ms */ |
| 547 | break; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 548 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
| 549 | ir_codes = ir_codes_dntv_live_dvbt_pro; |
| 550 | ir_type = IR_TYPE_PD; |
| 551 | ir->sampling = 0xff00; /* address */ |
| 552 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | } |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 554 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | if (NULL == ir_codes) { |
| 556 | kfree(ir); |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 557 | input_free_device(input_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | return -ENODEV; |
| 559 | } |
| 560 | |
| 561 | /* init input device */ |
| 562 | snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", |
| 563 | cx88_boards[core->board].name); |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 564 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 566 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
| 567 | input_dev->name = ir->name; |
| 568 | input_dev->phys = ir->phys; |
| 569 | input_dev->id.bustype = BUS_PCI; |
| 570 | input_dev->id.version = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | if (pci->subsystem_vendor) { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 572 | input_dev->id.vendor = pci->subsystem_vendor; |
| 573 | input_dev->id.product = pci->subsystem_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } else { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 575 | input_dev->id.vendor = pci->vendor; |
| 576 | input_dev->id.product = pci->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | } |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 578 | input_dev->cdev.dev = &pci->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | /* record handles to ourself */ |
| 580 | ir->core = core; |
| 581 | core->ir = ir; |
| 582 | |
| 583 | if (ir->polling) { |
| 584 | INIT_WORK(&ir->work, cx88_ir_work, ir); |
| 585 | init_timer(&ir->timer); |
| 586 | ir->timer.function = ir_timer; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 587 | ir->timer.data = (unsigned long)ir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | schedule_work(&ir->work); |
| 589 | } |
| 590 | if (ir->sampling) { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 591 | core->pci_irqmask |= (1 << 18); /* IR_SMP_INT */ |
| 592 | cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */ |
| 593 | cx_write(MO_DDSCFG_IO, 0x5); /* enable */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | /* all done */ |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 597 | input_register_device(ir->input); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | int cx88_ir_fini(struct cx88_core *core) |
| 603 | { |
| 604 | struct cx88_IR *ir = core->ir; |
| 605 | |
| 606 | /* skip detach on non attached boards */ |
| 607 | if (NULL == ir) |
| 608 | return 0; |
| 609 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 610 | if (ir->sampling) { |
| 611 | cx_write(MO_DDSCFG_IO, 0x0); |
| 612 | core->pci_irqmask &= ~(1 << 18); |
| 613 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | if (ir->polling) { |
| 615 | del_timer(&ir->timer); |
| 616 | flush_scheduled_work(); |
| 617 | } |
| 618 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 619 | input_unregister_device(ir->input); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | kfree(ir); |
| 621 | |
| 622 | /* done */ |
| 623 | core->ir = NULL; |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | /* ---------------------------------------------------------------------- */ |
| 628 | |
| 629 | void cx88_ir_irq(struct cx88_core *core) |
| 630 | { |
| 631 | struct cx88_IR *ir = core->ir; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 632 | u32 samples, ircode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | int i; |
| 634 | |
| 635 | if (NULL == ir) |
| 636 | return; |
| 637 | if (!ir->sampling) |
| 638 | return; |
| 639 | |
| 640 | samples = cx_read(MO_SAMPLE_IO); |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 641 | if (0 != samples && 0xffffffff != samples) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | /* record sample data */ |
| 643 | if (ir->scount < ARRAY_SIZE(ir->samples)) |
| 644 | ir->samples[ir->scount++] = samples; |
| 645 | return; |
| 646 | } |
| 647 | if (!ir->scount) { |
| 648 | /* nothing to sample */ |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 649 | if (ir->ir.keypressed && time_after(jiffies, ir->release)) |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 650 | ir_input_nokey(ir->input, &ir->ir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | return; |
| 652 | } |
| 653 | |
| 654 | /* have a complete sample */ |
| 655 | if (ir->scount < ARRAY_SIZE(ir->samples)) |
| 656 | ir->samples[ir->scount++] = samples; |
| 657 | for (i = 0; i < ir->scount; i++) |
| 658 | ir->samples[i] = ~ir->samples[i]; |
| 659 | if (ir_debug) |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 660 | ir_dump_samples(ir->samples, ir->scount); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
| 662 | /* decode it */ |
| 663 | switch (core->board) { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 664 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 665 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 666 | ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); |
| 667 | |
| 668 | if (ircode == 0xffffffff) { /* decoding error */ |
| 669 | ir_dprintk("pulse distance decoding error\n"); |
| 670 | break; |
| 671 | } |
| 672 | |
| 673 | ir_dprintk("pulse distance decoded: %x\n", ircode); |
| 674 | |
| 675 | if (ircode == 0) { /* key still pressed */ |
| 676 | ir_dprintk("pulse distance decoded repeat code\n"); |
| 677 | ir->release = jiffies + msecs_to_jiffies(120); |
| 678 | break; |
| 679 | } |
| 680 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 681 | if ((ircode & 0xffff) != (ir->sampling & 0xffff)) { /* wrong address */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 682 | ir_dprintk("pulse distance decoded wrong address\n"); |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 683 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */ |
| 687 | ir_dprintk("pulse distance decoded wrong check sum\n"); |
| 688 | break; |
| 689 | } |
| 690 | |
| 691 | ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); |
| 692 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 693 | ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 694 | ir->release = jiffies + msecs_to_jiffies(120); |
| 695 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | case CX88_BOARD_HAUPPAUGE: |
| 697 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
Steven Toth | fb56cb6 | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 698 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
| 699 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 700 | ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); |
| 701 | ir_dprintk("biphase decoded: %x\n", ircode); |
| 702 | if ((ircode & 0xfffff000) != 0x3000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | break; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 704 | ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | ir->release = jiffies + msecs_to_jiffies(120); |
| 706 | break; |
| 707 | } |
| 708 | |
| 709 | ir->scount = 0; |
| 710 | return; |
| 711 | } |
| 712 | |
| 713 | /* ---------------------------------------------------------------------- */ |
| 714 | |
| 715 | MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe"); |
| 716 | MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls"); |
| 717 | MODULE_LICENSE("GPL"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | /* |
| 719 | * Local variables: |
| 720 | * c-basic-offset: 8 |
| 721 | * End: |
| 722 | */ |