]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * |
3 | * handle saa7134 IR remotes via linux kernel input layer. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | * | |
19 | */ | |
20 | ||
21 | #include <linux/module.h> | |
1da177e4 LT |
22 | #include <linux/init.h> |
23 | #include <linux/delay.h> | |
1da177e4 | 24 | #include <linux/interrupt.h> |
5a0e3ad6 | 25 | #include <linux/slab.h> |
1da177e4 LT |
26 | |
27 | #include "saa7134-reg.h" | |
28 | #include "saa7134.h" | |
29 | ||
d302548a | 30 | #define MODULE_NAME "saa7134" |
727e625c | 31 | |
ff699e6b | 32 | static unsigned int disable_ir; |
1da177e4 LT |
33 | module_param(disable_ir, int, 0444); |
34 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); | |
35 | ||
ff699e6b | 36 | static unsigned int ir_debug; |
1da177e4 LT |
37 | module_param(ir_debug, int, 0644); |
38 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); | |
39 | ||
ff699e6b | 40 | static int pinnacle_remote; |
b93eedb6 SP |
41 | module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */ |
42 | MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)"); | |
43 | ||
1da177e4 LT |
44 | #define dprintk(fmt, arg...) if (ir_debug) \ |
45 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) | |
ac9cd976 | 46 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ |
1df8e986 | 47 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg) |
1da177e4 | 48 | |
bce8d0fe | 49 | /* Helper function for raw decoding at GPIO16 or GPIO18 */ |
a3572c34 | 50 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev); |
9160723e | 51 | |
ac9cd976 | 52 | /* -------------------- GPIO generic keycode builder -------------------- */ |
1da177e4 LT |
53 | |
54 | static int build_key(struct saa7134_dev *dev) | |
55 | { | |
a6e3b81f | 56 | struct saa7134_card_ir *ir = dev->remote; |
1da177e4 LT |
57 | u32 gpio, data; |
58 | ||
0938e319 P |
59 | /* here comes the additional handshake steps for some cards */ |
60 | switch (dev->board) { | |
61 | case SAA7134_BOARD_GOTVIEW_7135: | |
62 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80); | |
63 | saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80); | |
64 | break; | |
65 | } | |
1da177e4 LT |
66 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
67 | saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); | |
68 | saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); | |
69 | ||
70 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); | |
4ac97914 MCC |
71 | if (ir->polling) { |
72 | if (ir->last_gpio == gpio) | |
73 | return 0; | |
74 | ir->last_gpio = gpio; | |
75 | } | |
1da177e4 | 76 | |
4ac97914 | 77 | data = ir_extract_bits(gpio, ir->mask_keycode); |
1da177e4 LT |
78 | dprintk("build_key gpio=0x%x mask=0x%x data=%d\n", |
79 | gpio, ir->mask_keycode, data); | |
80 | ||
26d5f3a3 MCC |
81 | switch (dev->board) { |
82 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: | |
83 | if (data == ir->mask_keycode) | |
ca86674b | 84 | rc_keyup(ir->dev); |
26d5f3a3 | 85 | else |
ca86674b | 86 | rc_keydown_notimeout(ir->dev, data, 0); |
26d5f3a3 MCC |
87 | return 0; |
88 | } | |
89 | ||
0602fbb2 PM |
90 | if (ir->polling) { |
91 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || | |
92 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { | |
ca86674b | 93 | rc_keydown_notimeout(ir->dev, data, 0); |
0602fbb2 | 94 | } else { |
ca86674b | 95 | rc_keyup(ir->dev); |
0602fbb2 | 96 | } |
1da177e4 | 97 | } |
0602fbb2 PM |
98 | else { /* IRQ driven mode - handle key press and release in one go */ |
99 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || | |
100 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { | |
ca86674b MCC |
101 | rc_keydown_notimeout(ir->dev, data, 0); |
102 | rc_keyup(ir->dev); | |
0602fbb2 PM |
103 | } |
104 | } | |
105 | ||
1da177e4 LT |
106 | return 0; |
107 | } | |
108 | ||
ac9cd976 RC |
109 | /* --------------------- Chip specific I2C key builders ----------------- */ |
110 | ||
d995a187 LK |
111 | static int get_key_flydvb_trio(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
112 | { | |
113 | int gpio; | |
114 | int attempt = 0; | |
115 | unsigned char b; | |
116 | ||
117 | /* We need this to access GPI Used by the saa_readl macro. */ | |
118 | struct saa7134_dev *dev = ir->c->adapter->algo_data; | |
119 | ||
120 | if (dev == NULL) { | |
129c34d8 DC |
121 | i2cdprintk("get_key_flydvb_trio: " |
122 | "ir->c->adapter->algo_data is NULL!\n"); | |
d995a187 LK |
123 | return -EIO; |
124 | } | |
125 | ||
126 | /* rising SAA7134_GPIGPRESCAN reads the status */ | |
127 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
128 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
129 | ||
130 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); | |
131 | ||
132 | if (0x40000 & ~gpio) | |
133 | return 0; /* No button press */ | |
134 | ||
135 | /* No button press - only before first key pressed */ | |
136 | if (b == 0xFF) | |
137 | return 0; | |
138 | ||
139 | /* poll IR chip */ | |
140 | /* weak up the IR chip */ | |
141 | b = 0; | |
142 | ||
143 | while (1 != i2c_master_send(ir->c, &b, 1)) { | |
144 | if ((attempt++) < 10) { | |
145 | /* | |
146 | * wait a bit for next attempt - | |
147 | * I don't know how make it better | |
148 | */ | |
149 | msleep(10); | |
150 | continue; | |
151 | } | |
152 | i2cdprintk("send wake up byte to pic16C505 (IR chip)" | |
153 | "failed %dx\n", attempt); | |
154 | return -EIO; | |
155 | } | |
156 | if (1 != i2c_master_recv(ir->c, &b, 1)) { | |
157 | i2cdprintk("read error\n"); | |
158 | return -EIO; | |
159 | } | |
160 | ||
161 | *ir_key = b; | |
162 | *ir_raw = b; | |
163 | return 1; | |
164 | } | |
165 | ||
ba340b40 BR |
166 | static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key, |
167 | u32 *ir_raw) | |
168 | { | |
169 | unsigned char b; | |
170 | int gpio; | |
171 | ||
172 | /* <dev> is needed to access GPIO. Used by the saa_readl macro. */ | |
c668f32d | 173 | struct saa7134_dev *dev = ir->c->adapter->algo_data; |
ba340b40 | 174 | if (dev == NULL) { |
129c34d8 DC |
175 | i2cdprintk("get_key_msi_tvanywhere_plus: " |
176 | "ir->c->adapter->algo_data is NULL!\n"); | |
ba340b40 BR |
177 | return -EIO; |
178 | } | |
179 | ||
180 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ | |
181 | ||
182 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
183 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
184 | ||
185 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); | |
186 | ||
187 | /* GPIO&0x40 is pulsed low when a button is pressed. Don't do | |
188 | I2C receive if gpio&0x40 is not low. */ | |
189 | ||
190 | if (gpio & 0x40) | |
191 | return 0; /* No button press */ | |
192 | ||
193 | /* GPIO says there is a button press. Get it. */ | |
194 | ||
c668f32d | 195 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
ba340b40 BR |
196 | i2cdprintk("read error\n"); |
197 | return -EIO; | |
198 | } | |
199 | ||
200 | /* No button press */ | |
201 | ||
202 | if (b == 0xff) | |
203 | return 0; | |
204 | ||
205 | /* Button pressed */ | |
206 | ||
207 | dprintk("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b); | |
208 | *ir_key = b; | |
209 | *ir_raw = b; | |
210 | return 1; | |
211 | } | |
212 | ||
ac9cd976 RC |
213 | static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
214 | { | |
215 | unsigned char b; | |
216 | ||
217 | /* poll IR chip */ | |
c668f32d | 218 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
ac9cd976 RC |
219 | i2cdprintk("read error\n"); |
220 | return -EIO; | |
221 | } | |
222 | ||
223 | /* no button press */ | |
224 | if (b==0) | |
225 | return 0; | |
226 | ||
227 | /* repeating */ | |
228 | if (b & 0x80) | |
229 | return 1; | |
230 | ||
231 | *ir_key = b; | |
232 | *ir_raw = b; | |
233 | return 1; | |
234 | } | |
235 | ||
177aaaf8 TG |
236 | static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
237 | { | |
641269f9 | 238 | unsigned char buf[5]; |
177aaaf8 TG |
239 | |
240 | /* poll IR chip */ | |
c668f32d | 241 | if (5 != i2c_master_recv(ir->c, buf, 5)) |
177aaaf8 TG |
242 | return -EIO; |
243 | ||
641269f9 MCC |
244 | /* Check if some key were pressed */ |
245 | if (!(buf[0] & 0x80)) | |
177aaaf8 TG |
246 | return 0; |
247 | ||
641269f9 MCC |
248 | /* |
249 | * buf[3] & 0x80 is always high. | |
250 | * buf[3] & 0x40 is a parity bit. A repeat event is marked | |
251 | * by preserving it into two separate readings | |
252 | * buf[4] bits 0 and 1, and buf[1] and buf[2] are always | |
253 | * zero. | |
254 | */ | |
255 | *ir_key = 0x1fff & ((buf[3] << 8) | (buf[4] >> 2)); | |
256 | *ir_raw = *ir_key; | |
177aaaf8 TG |
257 | return 1; |
258 | } | |
259 | ||
e8018c9e AMT |
260 | |
261 | static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |
262 | { | |
263 | unsigned char data[12]; | |
264 | u32 gpio; | |
265 | ||
c668f32d | 266 | struct saa7134_dev *dev = ir->c->adapter->algo_data; |
e8018c9e AMT |
267 | |
268 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ | |
269 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
270 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
271 | ||
272 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); | |
273 | ||
616f8878 | 274 | if (0x400000 & ~gpio) |
e8018c9e AMT |
275 | return 0; /* No button press */ |
276 | ||
c668f32d | 277 | ir->c->addr = 0x5a >> 1; |
e8018c9e | 278 | |
c668f32d | 279 | if (12 != i2c_master_recv(ir->c, data, 12)) { |
e8018c9e AMT |
280 | i2cdprintk("read error\n"); |
281 | return -EIO; | |
282 | } | |
e8018c9e | 283 | |
2d21ffe0 DB |
284 | if (data[9] != (unsigned char)(~data[8])) |
285 | return 0; | |
286 | ||
b0ddb0f3 DH |
287 | *ir_raw = ((data[10] << 16) | (data[11] << 8) | (data[9] << 0)); |
288 | *ir_key = *ir_raw; | |
e8018c9e AMT |
289 | |
290 | return 1; | |
291 | } | |
292 | ||
1c22dad8 MCC |
293 | /* Common (grey or coloured) pinnacle PCTV remote handling |
294 | * | |
295 | */ | |
296 | static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, | |
297 | int parity_offset, int marker, int code_modulo) | |
298 | { | |
299 | unsigned char b[4]; | |
300 | unsigned int start = 0,parity = 0,code = 0; | |
301 | ||
302 | /* poll IR chip */ | |
c668f32d | 303 | if (4 != i2c_master_recv(ir->c, b, 4)) { |
1c22dad8 MCC |
304 | i2cdprintk("read error\n"); |
305 | return -EIO; | |
306 | } | |
307 | ||
308 | for (start = 0; start < ARRAY_SIZE(b); start++) { | |
309 | if (b[start] == marker) { | |
310 | code=b[(start+parity_offset + 1) % 4]; | |
311 | parity=b[(start+parity_offset) % 4]; | |
312 | } | |
313 | } | |
314 | ||
315 | /* Empty Request */ | |
316 | if (parity == 0) | |
317 | return 0; | |
318 | ||
319 | /* Repeating... */ | |
320 | if (ir->old == parity) | |
321 | return 0; | |
322 | ||
323 | ir->old = parity; | |
324 | ||
325 | /* drop special codes when a key is held down a long time for the grey controller | |
326 | In this case, the second bit of the code is asserted */ | |
327 | if (marker == 0xfe && (code & 0x40)) | |
328 | return 0; | |
329 | ||
330 | code %= code_modulo; | |
331 | ||
332 | *ir_raw = code; | |
333 | *ir_key = code; | |
334 | ||
335 | i2cdprintk("Pinnacle PCTV key %02x\n", code); | |
336 | ||
337 | return 1; | |
338 | } | |
339 | ||
340 | /* The grey pinnacle PCTV remote | |
341 | * | |
342 | * There are one issue with this remote: | |
343 | * - I2c packet does not change when the same key is pressed quickly. The workaround | |
344 | * is to hold down each key for about half a second, so that another code is generated | |
345 | * in the i2c packet, and the function can distinguish key presses. | |
346 | * | |
347 | * Sylvain Pasche <sylvain.pasche@gmail.com> | |
348 | */ | |
349 | static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |
350 | { | |
351 | ||
352 | return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff); | |
353 | } | |
354 | ||
355 | ||
356 | /* The new pinnacle PCTV remote (with the colored buttons) | |
357 | * | |
358 | * Ricardo Cerqueira <v4l@cerqueira.org> | |
359 | */ | |
360 | static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |
361 | { | |
362 | /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE | |
363 | * | |
364 | * this is the only value that results in 42 unique | |
365 | * codes < 128 | |
366 | */ | |
367 | ||
368 | return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88); | |
369 | } | |
370 | ||
1da177e4 LT |
371 | void saa7134_input_irq(struct saa7134_dev *dev) |
372 | { | |
a6e3b81f | 373 | struct saa7134_card_ir *ir; |
716aab44 MCC |
374 | |
375 | if (!dev || !dev->remote) | |
376 | return; | |
377 | ||
378 | ir = dev->remote; | |
379 | if (!ir->running) | |
380 | return; | |
1da177e4 | 381 | |
bce8d0fe | 382 | if (!ir->polling && !ir->raw_decode) { |
1da177e4 | 383 | build_key(dev); |
a3572c34 MCC |
384 | } else if (ir->raw_decode) { |
385 | saa7134_raw_decode_irq(dev); | |
9160723e | 386 | } |
1da177e4 LT |
387 | } |
388 | ||
389 | static void saa7134_input_timer(unsigned long data) | |
390 | { | |
b4ba7884 | 391 | struct saa7134_dev *dev = (struct saa7134_dev *)data; |
a6e3b81f | 392 | struct saa7134_card_ir *ir = dev->remote; |
1da177e4 LT |
393 | |
394 | build_key(dev); | |
b4ba7884 | 395 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); |
1da177e4 LT |
396 | } |
397 | ||
e051f69a | 398 | static void ir_raw_decode_timer_end(unsigned long data) |
a3572c34 MCC |
399 | { |
400 | struct saa7134_dev *dev = (struct saa7134_dev *)data; | |
a6e3b81f | 401 | struct saa7134_card_ir *ir = dev->remote; |
a3572c34 | 402 | |
ada39630 | 403 | ir_raw_event_handle(dev->remote->dev); |
9f154782 | 404 | |
a6e3b81f | 405 | ir->active = false; |
a3572c34 MCC |
406 | } |
407 | ||
716aab44 | 408 | static int __saa7134_ir_start(void *priv) |
b07b4783 | 409 | { |
716aab44 | 410 | struct saa7134_dev *dev = priv; |
a6e3b81f | 411 | struct saa7134_card_ir *ir; |
716aab44 | 412 | |
651c7a5f | 413 | if (!dev || !dev->remote) |
716aab44 MCC |
414 | return -EINVAL; |
415 | ||
416 | ir = dev->remote; | |
02108949 | 417 | if (ir->running) |
716aab44 | 418 | return 0; |
02108949 | 419 | |
8c1476ff VS |
420 | /* Moved here from saa7134_input_init1() because the latter |
421 | * is not called on device resume */ | |
422 | switch (dev->board) { | |
423 | case SAA7134_BOARD_MD2819: | |
424 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: | |
425 | case SAA7134_BOARD_AVERMEDIA_305: | |
426 | case SAA7134_BOARD_AVERMEDIA_307: | |
427 | case SAA7134_BOARD_AVERMEDIA_STUDIO_305: | |
428 | case SAA7134_BOARD_AVERMEDIA_STUDIO_505: | |
429 | case SAA7134_BOARD_AVERMEDIA_STUDIO_307: | |
430 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507: | |
431 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA: | |
432 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: | |
433 | case SAA7134_BOARD_AVERMEDIA_M102: | |
434 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: | |
435 | /* Without this we won't receive key up events */ | |
436 | saa_setb(SAA7134_GPIO_GPMODE0, 0x4); | |
437 | saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); | |
438 | break; | |
439 | case SAA7134_BOARD_AVERMEDIA_777: | |
440 | case SAA7134_BOARD_AVERMEDIA_A16AR: | |
441 | /* Without this we won't receive key up events */ | |
442 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); | |
443 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | |
444 | break; | |
445 | case SAA7134_BOARD_AVERMEDIA_A16D: | |
446 | /* Without this we won't receive key up events */ | |
447 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); | |
448 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | |
449 | break; | |
450 | case SAA7134_BOARD_GOTVIEW_7135: | |
451 | saa_setb(SAA7134_GPIO_GPMODE1, 0x80); | |
452 | break; | |
453 | } | |
454 | ||
a6e3b81f | 455 | ir->running = true; |
651c7a5f DH |
456 | ir->active = false; |
457 | ||
b07b4783 | 458 | if (ir->polling) { |
b4ba7884 DT |
459 | setup_timer(&ir->timer, saa7134_input_timer, |
460 | (unsigned long)dev); | |
7c8352d1 | 461 | ir->timer.expires = jiffies + HZ; |
b07b4783 | 462 | add_timer(&ir->timer); |
a3572c34 MCC |
463 | } else if (ir->raw_decode) { |
464 | /* set timer_end for code completion */ | |
7c8352d1 | 465 | setup_timer(&ir->timer, ir_raw_decode_timer_end, |
651c7a5f | 466 | (unsigned long)dev); |
b07b4783 | 467 | } |
716aab44 MCC |
468 | |
469 | return 0; | |
b07b4783 DT |
470 | } |
471 | ||
716aab44 | 472 | static void __saa7134_ir_stop(void *priv) |
b07b4783 | 473 | { |
716aab44 | 474 | struct saa7134_dev *dev = priv; |
a6e3b81f | 475 | struct saa7134_card_ir *ir; |
716aab44 | 476 | |
651c7a5f | 477 | if (!dev || !dev->remote) |
716aab44 MCC |
478 | return; |
479 | ||
480 | ir = dev->remote; | |
02108949 MCC |
481 | if (!ir->running) |
482 | return; | |
651c7a5f | 483 | |
7c8352d1 | 484 | if (ir->polling || ir->raw_decode) |
651c7a5f | 485 | del_timer_sync(&ir->timer); |
a3572c34 | 486 | |
651c7a5f | 487 | ir->active = false; |
a6e3b81f | 488 | ir->running = false; |
716aab44 MCC |
489 | |
490 | return; | |
491 | } | |
492 | ||
493 | int saa7134_ir_start(struct saa7134_dev *dev) | |
494 | { | |
495 | if (dev->remote->users) | |
496 | return __saa7134_ir_start(dev); | |
497 | ||
498 | return 0; | |
499 | } | |
500 | ||
501 | void saa7134_ir_stop(struct saa7134_dev *dev) | |
502 | { | |
503 | if (dev->remote->users) | |
504 | __saa7134_ir_stop(dev); | |
505 | } | |
506 | ||
d8b4b582 | 507 | static int saa7134_ir_open(struct rc_dev *rc) |
716aab44 | 508 | { |
d8b4b582 | 509 | struct saa7134_dev *dev = rc->priv; |
716aab44 MCC |
510 | |
511 | dev->remote->users++; | |
512 | return __saa7134_ir_start(dev); | |
513 | } | |
514 | ||
d8b4b582 | 515 | static void saa7134_ir_close(struct rc_dev *rc) |
716aab44 | 516 | { |
d8b4b582 | 517 | struct saa7134_dev *dev = rc->priv; |
716aab44 MCC |
518 | |
519 | dev->remote->users--; | |
520 | if (!dev->remote->users) | |
521 | __saa7134_ir_stop(dev); | |
02108949 MCC |
522 | } |
523 | ||
1da177e4 LT |
524 | int saa7134_input_init1(struct saa7134_dev *dev) |
525 | { | |
a6e3b81f | 526 | struct saa7134_card_ir *ir; |
d8b4b582 | 527 | struct rc_dev *rc; |
02858eed | 528 | char *ir_codes = NULL; |
1da177e4 LT |
529 | u32 mask_keycode = 0; |
530 | u32 mask_keydown = 0; | |
531 | u32 mask_keyup = 0; | |
651c7a5f DH |
532 | unsigned polling = 0; |
533 | bool raw_decode = false; | |
b07b4783 | 534 | int err; |
1da177e4 | 535 | |
cb2444df | 536 | if (dev->has_remote != SAA7134_REMOTE_GPIO) |
1da177e4 LT |
537 | return -ENODEV; |
538 | if (disable_ir) | |
539 | return -ENODEV; | |
540 | ||
541 | /* detect & configure */ | |
542 | switch (dev->board) { | |
543 | case SAA7134_BOARD_FLYVIDEO2000: | |
544 | case SAA7134_BOARD_FLYVIDEO3000: | |
4ac97914 | 545 | case SAA7134_BOARD_FLYTVPLATINUM_FM: |
6af90ab5 | 546 | case SAA7134_BOARD_FLYTVPLATINUM_MINI2: |
23389b88 | 547 | case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM: |
02858eed | 548 | ir_codes = RC_MAP_FLYVIDEO; |
1da177e4 LT |
549 | mask_keycode = 0xEC00000; |
550 | mask_keydown = 0x0040000; | |
551 | break; | |
552 | case SAA7134_BOARD_CINERGY400: | |
553 | case SAA7134_BOARD_CINERGY600: | |
554 | case SAA7134_BOARD_CINERGY600_MK3: | |
02858eed | 555 | ir_codes = RC_MAP_CINERGY; |
1da177e4 LT |
556 | mask_keycode = 0x00003f; |
557 | mask_keyup = 0x040000; | |
558 | break; | |
559 | case SAA7134_BOARD_ECS_TVP3XP: | |
560 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: | |
02858eed | 561 | ir_codes = RC_MAP_EZTV; |
330a115a MCC |
562 | mask_keycode = 0x00017c; |
563 | mask_keyup = 0x000002; | |
1da177e4 | 564 | polling = 50; // ms |
330a115a MCC |
565 | break; |
566 | case SAA7134_BOARD_KWORLD_XPERT: | |
1da177e4 | 567 | case SAA7134_BOARD_AVACSSMARTTV: |
02858eed | 568 | ir_codes = RC_MAP_PIXELVIEW; |
1da177e4 LT |
569 | mask_keycode = 0x00001F; |
570 | mask_keyup = 0x000020; | |
571 | polling = 50; // ms | |
572 | break; | |
573 | case SAA7134_BOARD_MD2819: | |
ac19ecc6 | 574 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: |
1da177e4 LT |
575 | case SAA7134_BOARD_AVERMEDIA_305: |
576 | case SAA7134_BOARD_AVERMEDIA_307: | |
ac19ecc6 | 577 | case SAA7134_BOARD_AVERMEDIA_STUDIO_305: |
5a5e1da5 | 578 | case SAA7134_BOARD_AVERMEDIA_STUDIO_505: |
ac19ecc6 | 579 | case SAA7134_BOARD_AVERMEDIA_STUDIO_307: |
3ac706d2 | 580 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507: |
df0dbbe2 | 581 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA: |
ac19ecc6 | 582 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: |
d2761f22 | 583 | case SAA7134_BOARD_AVERMEDIA_M102: |
6a2d802c | 584 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: |
02858eed | 585 | ir_codes = RC_MAP_AVERMEDIA; |
1da177e4 LT |
586 | mask_keycode = 0x0007C8; |
587 | mask_keydown = 0x000010; | |
588 | polling = 50; // ms | |
8c1476ff | 589 | /* GPIO stuff moved to __saa7134_ir_start() */ |
1da177e4 | 590 | break; |
36f6bb97 | 591 | case SAA7134_BOARD_AVERMEDIA_M135A: |
63fc31e8 | 592 | ir_codes = RC_MAP_AVERMEDIA_M135A; |
2f16f631 MCC |
593 | mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */ |
594 | mask_keyup = 0x0040000; | |
d152b8b6 | 595 | mask_keycode = 0xffff; |
651c7a5f | 596 | raw_decode = true; |
36f6bb97 | 597 | break; |
9e1d9e7b HRK |
598 | case SAA7134_BOARD_AVERMEDIA_M733A: |
599 | ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6; | |
600 | mask_keydown = 0x0040000; | |
601 | mask_keyup = 0x0040000; | |
602 | mask_keycode = 0xffff; | |
651c7a5f | 603 | raw_decode = true; |
9e1d9e7b | 604 | break; |
450efcfd | 605 | case SAA7134_BOARD_AVERMEDIA_777: |
29e0f1a1 | 606 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
02858eed | 607 | ir_codes = RC_MAP_AVERMEDIA; |
450efcfd | 608 | mask_keycode = 0x02F200; |
609 | mask_keydown = 0x000400; | |
610 | polling = 50; // ms | |
8c1476ff | 611 | /* GPIO stuff moved to __saa7134_ir_start() */ |
4dd7406e | 612 | break; |
6e501a3f | 613 | case SAA7134_BOARD_AVERMEDIA_A16D: |
02858eed | 614 | ir_codes = RC_MAP_AVERMEDIA_A16D; |
6e501a3f TF |
615 | mask_keycode = 0x02F200; |
616 | mask_keydown = 0x000400; | |
617 | polling = 50; /* ms */ | |
8c1476ff | 618 | /* GPIO stuff moved to __saa7134_ir_start() */ |
6e501a3f | 619 | break; |
4ac97914 | 620 | case SAA7134_BOARD_KWORLD_TERMINATOR: |
02858eed | 621 | ir_codes = RC_MAP_PIXELVIEW; |
dc2286cf JW |
622 | mask_keycode = 0x00001f; |
623 | mask_keyup = 0x000060; | |
624 | polling = 50; // ms | |
625 | break; | |
ac19ecc6 MCC |
626 | case SAA7134_BOARD_MANLI_MTV001: |
627 | case SAA7134_BOARD_MANLI_MTV002: | |
02858eed | 628 | ir_codes = RC_MAP_MANLI; |
b34dddbe DB |
629 | mask_keycode = 0x001f00; |
630 | mask_keyup = 0x004000; | |
631 | polling = 50; /* ms */ | |
632 | break; | |
a8ff417e | 633 | case SAA7134_BOARD_BEHOLD_409FM: |
e8018c9e AMT |
634 | case SAA7134_BOARD_BEHOLD_401: |
635 | case SAA7134_BOARD_BEHOLD_403: | |
636 | case SAA7134_BOARD_BEHOLD_403FM: | |
637 | case SAA7134_BOARD_BEHOLD_405: | |
638 | case SAA7134_BOARD_BEHOLD_405FM: | |
639 | case SAA7134_BOARD_BEHOLD_407: | |
640 | case SAA7134_BOARD_BEHOLD_407FM: | |
641 | case SAA7134_BOARD_BEHOLD_409: | |
642 | case SAA7134_BOARD_BEHOLD_505FM: | |
9c6f97a0 DB |
643 | case SAA7134_BOARD_BEHOLD_505RDS_MK5: |
644 | case SAA7134_BOARD_BEHOLD_505RDS_MK3: | |
e8018c9e | 645 | case SAA7134_BOARD_BEHOLD_507_9FM: |
84d728c3 DB |
646 | case SAA7134_BOARD_BEHOLD_507RDS_MK3: |
647 | case SAA7134_BOARD_BEHOLD_507RDS_MK5: | |
02858eed | 648 | ir_codes = RC_MAP_MANLI; |
b34dddbe DB |
649 | mask_keycode = 0x003f00; |
650 | mask_keyup = 0x004000; | |
651 | polling = 50; /* ms */ | |
652 | break; | |
653 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | |
02858eed | 654 | ir_codes = RC_MAP_BEHOLD_COLUMBUS; |
b34dddbe | 655 | mask_keycode = 0x003f00; |
ac19ecc6 | 656 | mask_keyup = 0x004000; |
ac19ecc6 MCC |
657 | polling = 50; // ms |
658 | break; | |
17ce1ff9 | 659 | case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: |
02858eed | 660 | ir_codes = RC_MAP_PCTV_SEDNA; |
c3d93192 PM |
661 | mask_keycode = 0x001f00; |
662 | mask_keyup = 0x004000; | |
663 | polling = 50; // ms | |
664 | break; | |
4ac97914 | 665 | case SAA7134_BOARD_GOTVIEW_7135: |
02858eed | 666 | ir_codes = RC_MAP_GOTVIEW7135; |
0938e319 | 667 | mask_keycode = 0x0003CC; |
6b961440 | 668 | mask_keydown = 0x000010; |
0938e319 | 669 | polling = 5; /* ms */ |
8c1476ff | 670 | /* GPIO stuff moved to __saa7134_ir_start() */ |
6b961440 | 671 | break; |
1da177e4 | 672 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: |
2a9a9a84 | 673 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: |
330a115a | 674 | case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: |
02858eed | 675 | ir_codes = RC_MAP_VIDEOMATE_TV_PVR; |
1da177e4 LT |
676 | mask_keycode = 0x00003F; |
677 | mask_keyup = 0x400000; | |
678 | polling = 50; // ms | |
679 | break; | |
b04c1baf | 680 | case SAA7134_BOARD_PROTEUS_2309: |
02858eed | 681 | ir_codes = RC_MAP_PROTEUS_2309; |
b04c1baf MM |
682 | mask_keycode = 0x00007F; |
683 | mask_keyup = 0x000080; | |
684 | polling = 50; // ms | |
685 | break; | |
4ac97914 MCC |
686 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
687 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: | |
02858eed | 688 | ir_codes = RC_MAP_VIDEOMATE_TV_PVR; |
fea095fe NS |
689 | mask_keycode = 0x003F00; |
690 | mask_keyup = 0x040000; | |
691 | break; | |
f5c965ab | 692 | case SAA7134_BOARD_FLYDVBS_LR300: |
3d8466ec | 693 | case SAA7134_BOARD_FLYDVBT_LR301: |
a8029170 | 694 | case SAA7134_BOARD_FLYDVBTDUO: |
02858eed | 695 | ir_codes = RC_MAP_FLYDVB; |
3d8466ec GG |
696 | mask_keycode = 0x0001F00; |
697 | mask_keydown = 0x0040000; | |
698 | break; | |
9160723e | 699 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
904ab884 | 700 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
dfb4ba1e | 701 | case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: |
02858eed | 702 | ir_codes = RC_MAP_ASUS_PC39; |
fe8b6713 MCC |
703 | mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */ |
704 | mask_keyup = 0x0040000; | |
705 | mask_keycode = 0xffff; | |
651c7a5f | 706 | raw_decode = true; |
9160723e | 707 | break; |
c36c459a JPS |
708 | case SAA7134_BOARD_ENCORE_ENLTV: |
709 | case SAA7134_BOARD_ENCORE_ENLTV_FM: | |
02858eed | 710 | ir_codes = RC_MAP_ENCORE_ENLTV; |
c36c459a JPS |
711 | mask_keycode = 0x00007f; |
712 | mask_keyup = 0x040000; | |
713 | polling = 50; // ms | |
714 | break; | |
bf1ece6a | 715 | case SAA7134_BOARD_ENCORE_ENLTV_FM53: |
d642f2f3 | 716 | case SAA7134_BOARD_ENCORE_ENLTV_FM3: |
02858eed | 717 | ir_codes = RC_MAP_ENCORE_ENLTV_FM53; |
bce8d0fe MCC |
718 | mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */ |
719 | mask_keyup = 0x0040000; | |
720 | mask_keycode = 0xffff; | |
651c7a5f | 721 | raw_decode = true; |
bf1ece6a | 722 | break; |
480f75ac | 723 | case SAA7134_BOARD_10MOONSTVMASTER3: |
02858eed | 724 | ir_codes = RC_MAP_ENCORE_ENLTV; |
480f75ac TW |
725 | mask_keycode = 0x5f80000; |
726 | mask_keyup = 0x8000000; | |
727 | polling = 50; //ms | |
728 | break; | |
f0ba356c | 729 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: |
02858eed | 730 | ir_codes = RC_MAP_GENIUS_TVGO_A11MCE; |
f0ba356c AP |
731 | mask_keycode = 0xff; |
732 | mask_keydown = 0xf00000; | |
733 | polling = 50; /* ms */ | |
734 | break; | |
9b000191 | 735 | case SAA7134_BOARD_REAL_ANGEL_220: |
02858eed | 736 | ir_codes = RC_MAP_REAL_AUDIO_220_32_KEYS; |
9b000191 MCC |
737 | mask_keycode = 0x3f00; |
738 | mask_keyup = 0x4000; | |
739 | polling = 50; /* ms */ | |
740 | break; | |
26d5f3a3 | 741 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: |
02858eed | 742 | ir_codes = RC_MAP_KWORLD_PLUS_TV_ANALOG; |
26d5f3a3 MCC |
743 | mask_keycode = 0x7f; |
744 | polling = 40; /* ms */ | |
745 | break; | |
ecfcfec8 | 746 | case SAA7134_BOARD_VIDEOMATE_S350: |
02858eed | 747 | ir_codes = RC_MAP_VIDEOMATE_S350; |
ecfcfec8 IL |
748 | mask_keycode = 0x003f00; |
749 | mask_keydown = 0x040000; | |
750 | break; | |
0700adec | 751 | case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S: |
02858eed | 752 | ir_codes = RC_MAP_WINFAST; |
0700adec MO |
753 | mask_keycode = 0x5f00; |
754 | mask_keyup = 0x020000; | |
117e1348 | 755 | polling = 50; /* ms */ |
0700adec | 756 | break; |
b7a0f2e7 | 757 | case SAA7134_BOARD_VIDEOMATE_M1F: |
0963119f | 758 | ir_codes = RC_MAP_VIDEOMATE_K100; |
b7a0f2e7 RM |
759 | mask_keycode = 0x0ff00; |
760 | mask_keyup = 0x040000; | |
761 | break; | |
da4b7b20 DH |
762 | case SAA7134_BOARD_HAUPPAUGE_HVR1150: |
763 | case SAA7134_BOARD_HAUPPAUGE_HVR1120: | |
764 | ir_codes = RC_MAP_HAUPPAUGE; | |
765 | mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */ | |
766 | mask_keyup = 0x0040000; | |
767 | mask_keycode = 0xffff; | |
768 | raw_decode = true; | |
769 | break; | |
1da177e4 LT |
770 | } |
771 | if (NULL == ir_codes) { | |
772 | printk("%s: Oops: IR config error [card=%d]\n", | |
773 | dev->name, dev->board); | |
774 | return -ENODEV; | |
775 | } | |
776 | ||
b7df3910 | 777 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
d8b4b582 DH |
778 | rc = rc_allocate_device(); |
779 | if (!ir || !rc) { | |
b07b4783 DT |
780 | err = -ENOMEM; |
781 | goto err_out_free; | |
b7df3910 | 782 | } |
1da177e4 | 783 | |
d8b4b582 | 784 | ir->dev = rc; |
02108949 MCC |
785 | dev->remote = ir; |
786 | ||
1da177e4 LT |
787 | /* init hardware-specific stuff */ |
788 | ir->mask_keycode = mask_keycode; | |
789 | ir->mask_keydown = mask_keydown; | |
790 | ir->mask_keyup = mask_keyup; | |
4ac97914 | 791 | ir->polling = polling; |
a3572c34 | 792 | ir->raw_decode = raw_decode; |
1da177e4 LT |
793 | |
794 | /* init input device */ | |
795 | snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)", | |
796 | saa7134_boards[dev->board].name); | |
797 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", | |
798 | pci_name(dev->pci)); | |
799 | ||
d8b4b582 DH |
800 | rc->priv = dev; |
801 | rc->open = saa7134_ir_open; | |
802 | rc->close = saa7134_ir_close; | |
626cf697 | 803 | if (raw_decode) |
d8b4b582 | 804 | rc->driver_type = RC_DRIVER_IR_RAW; |
626cf697 | 805 | |
d8b4b582 DH |
806 | rc->input_name = ir->name; |
807 | rc->input_phys = ir->phys; | |
808 | rc->input_id.bustype = BUS_PCI; | |
809 | rc->input_id.version = 1; | |
1da177e4 | 810 | if (dev->pci->subsystem_vendor) { |
d8b4b582 DH |
811 | rc->input_id.vendor = dev->pci->subsystem_vendor; |
812 | rc->input_id.product = dev->pci->subsystem_device; | |
1da177e4 | 813 | } else { |
d8b4b582 DH |
814 | rc->input_id.vendor = dev->pci->vendor; |
815 | rc->input_id.product = dev->pci->device; | |
1da177e4 | 816 | } |
d8b4b582 DH |
817 | rc->dev.parent = &dev->pci->dev; |
818 | rc->map_name = ir_codes; | |
819 | rc->driver_name = MODULE_NAME; | |
1da177e4 | 820 | |
d8b4b582 | 821 | err = rc_register_device(rc); |
b07b4783 | 822 | if (err) |
716aab44 | 823 | goto err_out_free; |
1da177e4 | 824 | |
1da177e4 | 825 | return 0; |
b07b4783 | 826 | |
716aab44 | 827 | err_out_free: |
d8b4b582 | 828 | rc_free_device(rc); |
b07b4783 | 829 | dev->remote = NULL; |
b07b4783 DT |
830 | kfree(ir); |
831 | return err; | |
1da177e4 LT |
832 | } |
833 | ||
834 | void saa7134_input_fini(struct saa7134_dev *dev) | |
835 | { | |
836 | if (NULL == dev->remote) | |
837 | return; | |
838 | ||
b07b4783 | 839 | saa7134_ir_stop(dev); |
d8b4b582 | 840 | rc_unregister_device(dev->remote->dev); |
1da177e4 LT |
841 | kfree(dev->remote); |
842 | dev->remote = NULL; | |
843 | } | |
844 | ||
c668f32d | 845 | void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
ac9cd976 | 846 | { |
43e16ea2 | 847 | struct i2c_board_info info; |
c668f32d JD |
848 | struct i2c_msg msg_msi = { |
849 | .addr = 0x50, | |
850 | .flags = I2C_M_RD, | |
851 | .len = 0, | |
852 | .buf = NULL, | |
853 | }; | |
c668f32d JD |
854 | int rc; |
855 | ||
ac9cd976 | 856 | if (disable_ir) { |
c668f32d | 857 | dprintk("IR has been disabled, not probing for i2c remote\n"); |
ac9cd976 RC |
858 | return; |
859 | } | |
860 | ||
43e16ea2 | 861 | memset(&info, 0, sizeof(struct i2c_board_info)); |
7aedd5ec | 862 | memset(&dev->init_data, 0, sizeof(dev->init_data)); |
43e16ea2 | 863 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); |
c668f32d | 864 | |
ac9cd976 RC |
865 | switch (dev->board) { |
866 | case SAA7134_BOARD_PINNACLE_PCTV_110i: | |
eb591af3 | 867 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
7aedd5ec | 868 | dev->init_data.name = "Pinnacle PCTV"; |
b93eedb6 | 869 | if (pinnacle_remote == 0) { |
7aedd5ec | 870 | dev->init_data.get_key = get_key_pinnacle_color; |
02858eed | 871 | dev->init_data.ir_codes = RC_MAP_PINNACLE_COLOR; |
43e16ea2 | 872 | info.addr = 0x47; |
b93eedb6 | 873 | } else { |
7aedd5ec | 874 | dev->init_data.get_key = get_key_pinnacle_grey; |
02858eed | 875 | dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY; |
43e16ea2 | 876 | info.addr = 0x47; |
b93eedb6 | 877 | } |
ac9cd976 RC |
878 | break; |
879 | case SAA7134_BOARD_UPMOST_PURPLE_TV: | |
7aedd5ec MCC |
880 | dev->init_data.name = "Purple TV"; |
881 | dev->init_data.get_key = get_key_purpletv; | |
02858eed | 882 | dev->init_data.ir_codes = RC_MAP_PURPLETV; |
aef02aa1 | 883 | info.addr = 0x7a; |
ac9cd976 | 884 | break; |
ba340b40 | 885 | case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: |
7aedd5ec MCC |
886 | dev->init_data.name = "MSI TV@nywhere Plus"; |
887 | dev->init_data.get_key = get_key_msi_tvanywhere_plus; | |
02858eed | 888 | dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS; |
c72ba8e6 MCC |
889 | /* |
890 | * MSI TV@nyware Plus requires more frequent polling | |
891 | * otherwise it will miss some keypresses | |
892 | */ | |
893 | dev->init_data.polling_interval = 50; | |
43e16ea2 | 894 | info.addr = 0x30; |
ec218a41 JD |
895 | /* MSI TV@nywhere Plus controller doesn't seem to |
896 | respond to probes unless we read something from | |
897 | an existing device. Weird... | |
898 | REVISIT: might no longer be needed */ | |
899 | rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1); | |
c429e7b6 | 900 | dprintk("probe 0x%02x @ %s: %s\n", |
ec218a41 JD |
901 | msg_msi.addr, dev->i2c_adap.name, |
902 | (1 == rc) ? "yes" : "no"); | |
ba340b40 | 903 | break; |
177aaaf8 | 904 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
7aedd5ec MCC |
905 | dev->init_data.name = "HVR 1110"; |
906 | dev->init_data.get_key = get_key_hvr1110; | |
af86ce79 | 907 | dev->init_data.ir_codes = RC_MAP_HAUPPAUGE; |
30093e8b | 908 | info.addr = 0x71; |
177aaaf8 | 909 | break; |
84d728c3 DB |
910 | case SAA7134_BOARD_BEHOLD_607FM_MK3: |
911 | case SAA7134_BOARD_BEHOLD_607FM_MK5: | |
912 | case SAA7134_BOARD_BEHOLD_609FM_MK3: | |
913 | case SAA7134_BOARD_BEHOLD_609FM_MK5: | |
914 | case SAA7134_BOARD_BEHOLD_607RDS_MK3: | |
915 | case SAA7134_BOARD_BEHOLD_607RDS_MK5: | |
916 | case SAA7134_BOARD_BEHOLD_609RDS_MK3: | |
917 | case SAA7134_BOARD_BEHOLD_609RDS_MK5: | |
e8018c9e | 918 | case SAA7134_BOARD_BEHOLD_M6: |
878cf2a5 DB |
919 | case SAA7134_BOARD_BEHOLD_M63: |
920 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: | |
02505271 | 921 | case SAA7134_BOARD_BEHOLD_H6: |
2012c87f | 922 | case SAA7134_BOARD_BEHOLD_X7: |
0faa2ed5 DB |
923 | case SAA7134_BOARD_BEHOLD_H7: |
924 | case SAA7134_BOARD_BEHOLD_A7: | |
7aedd5ec MCC |
925 | dev->init_data.name = "BeholdTV"; |
926 | dev->init_data.get_key = get_key_beholdm6xx; | |
02858eed | 927 | dev->init_data.ir_codes = RC_MAP_BEHOLD; |
52b66144 | 928 | dev->init_data.type = RC_TYPE_NEC; |
30093e8b | 929 | info.addr = 0x2d; |
ac9cd976 | 930 | break; |
d9a88e63 JD |
931 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: |
932 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | |
43e16ea2 | 933 | info.addr = 0x40; |
d9a88e63 | 934 | break; |
d995a187 LK |
935 | case SAA7134_BOARD_FLYDVB_TRIO: |
936 | dev->init_data.name = "FlyDVB Trio"; | |
937 | dev->init_data.get_key = get_key_flydvb_trio; | |
02858eed | 938 | dev->init_data.ir_codes = RC_MAP_FLYDVB; |
d995a187 LK |
939 | info.addr = 0x0b; |
940 | break; | |
30093e8b JD |
941 | default: |
942 | dprintk("No I2C IR support for board %x\n", dev->board); | |
943 | return; | |
ac9cd976 RC |
944 | } |
945 | ||
7aedd5ec | 946 | if (dev->init_data.name) |
43e16ea2 | 947 | info.platform_data = &dev->init_data; |
30093e8b | 948 | i2c_new_device(&dev->i2c_adap, &info); |
ac9cd976 | 949 | } |
9160723e | 950 | |
a3572c34 MCC |
951 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev) |
952 | { | |
651c7a5f DH |
953 | struct saa7134_card_ir *ir = dev->remote; |
954 | unsigned long timeout; | |
2f16f631 | 955 | int space; |
a3572c34 | 956 | |
a3572c34 MCC |
957 | /* Generate initial event */ |
958 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
959 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | |
2f16f631 | 960 | space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; |
724e2495 | 961 | ir_raw_event_store_edge(dev->remote->dev, space ? IR_SPACE : IR_PULSE); |
a3572c34 | 962 | |
9f154782 MCC |
963 | /* |
964 | * Wait 15 ms from the start of the first IR event before processing | |
965 | * the event. This time is enough for NEC protocol. May need adjustments | |
966 | * to work with other protocols. | |
967 | */ | |
968 | if (!ir->active) { | |
9800b5b6 | 969 | timeout = jiffies + msecs_to_jiffies(15); |
7c8352d1 | 970 | mod_timer(&ir->timer, timeout); |
a6e3b81f | 971 | ir->active = true; |
9f154782 | 972 | } |
a3572c34 MCC |
973 | |
974 | return 1; | |
975 | } |