diff options
author | Ricardo Cerqueira <v4l@cerqueira.org> | 2005-11-09 00:37:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:22 -0500 |
commit | ac9cd97640a8bcad75dc7305761365c3e339bbc5 (patch) | |
tree | a5061e3804d7cc5debbd0277ba10fedbd3a3b2b0 | |
parent | f4067fd46aa330d6df0a79b9dd0eb9555809c440 (diff) |
[PATCH] v4l: 817: saa713x keymaps and key builders were moved from ir kbd i2c c
- SAA713x keymaps and key builders were moved from ir-kbd-i2c.c
Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/media/video/em28xx/em28xx-input.c | 4 | ||||
-rw-r--r-- | drivers/media/video/ir-kbd-i2c.c | 202 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-i2c.c | 14 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-input.c | 202 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 5 |
5 files changed, 238 insertions, 189 deletions
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index 8681a793a0bf..e13585898f58 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c | |||
@@ -141,8 +141,10 @@ static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
141 | /* ----------------------------------------------------------------------- */ | 141 | /* ----------------------------------------------------------------------- */ |
142 | void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir) | 142 | void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir) |
143 | { | 143 | { |
144 | if (disable_ir) | 144 | if (disable_ir) { |
145 | ir->get_key=NULL; | ||
145 | return ; | 146 | return ; |
147 | } | ||
146 | 148 | ||
147 | /* detect & configure */ | 149 | /* detect & configure */ |
148 | switch (dev->model) { | 150 | switch (dev->model) { |
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 0cd1fc89b2d0..bdb3ba551360 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
@@ -82,104 +82,6 @@ static IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE] = { | |||
82 | [ 28 ] = KEY_MEDIA, /* PC/TV */ | 82 | [ 28 ] = KEY_MEDIA, /* PC/TV */ |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = { | ||
86 | [ 0x3 ] = KEY_POWER, | ||
87 | [ 0x6f ] = KEY_MUTE, | ||
88 | [ 0x10 ] = KEY_BACKSPACE, /* Recall */ | ||
89 | |||
90 | [ 0x11 ] = KEY_KP0, | ||
91 | [ 0x4 ] = KEY_KP1, | ||
92 | [ 0x5 ] = KEY_KP2, | ||
93 | [ 0x6 ] = KEY_KP3, | ||
94 | [ 0x8 ] = KEY_KP4, | ||
95 | [ 0x9 ] = KEY_KP5, | ||
96 | [ 0xa ] = KEY_KP6, | ||
97 | [ 0xc ] = KEY_KP7, | ||
98 | [ 0xd ] = KEY_KP8, | ||
99 | [ 0xe ] = KEY_KP9, | ||
100 | [ 0x12 ] = KEY_KPDOT, /* 100+ */ | ||
101 | |||
102 | [ 0x7 ] = KEY_VOLUMEUP, | ||
103 | [ 0xb ] = KEY_VOLUMEDOWN, | ||
104 | [ 0x1a ] = KEY_KPPLUS, | ||
105 | [ 0x18 ] = KEY_KPMINUS, | ||
106 | [ 0x15 ] = KEY_UP, | ||
107 | [ 0x1d ] = KEY_DOWN, | ||
108 | [ 0xf ] = KEY_CHANNELUP, | ||
109 | [ 0x13 ] = KEY_CHANNELDOWN, | ||
110 | [ 0x48 ] = KEY_ZOOM, | ||
111 | |||
112 | [ 0x1b ] = KEY_VIDEO, /* Video source */ | ||
113 | [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */ | ||
114 | [ 0x19 ] = KEY_SEARCH, /* Auto Scan */ | ||
115 | |||
116 | [ 0x4b ] = KEY_RECORD, | ||
117 | [ 0x46 ] = KEY_PLAY, | ||
118 | [ 0x45 ] = KEY_PAUSE, /* Pause */ | ||
119 | [ 0x44 ] = KEY_STOP, | ||
120 | [ 0x40 ] = KEY_FORWARD, /* Forward ? */ | ||
121 | [ 0x42 ] = KEY_REWIND, /* Backward ? */ | ||
122 | |||
123 | }; | ||
124 | |||
125 | static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = { | ||
126 | [ 0x59 ] = KEY_MUTE, | ||
127 | [ 0x4a ] = KEY_POWER, | ||
128 | |||
129 | [ 0x18 ] = KEY_TEXT, | ||
130 | [ 0x26 ] = KEY_TV, | ||
131 | [ 0x3d ] = KEY_PRINT, | ||
132 | |||
133 | [ 0x48 ] = KEY_RED, | ||
134 | [ 0x04 ] = KEY_GREEN, | ||
135 | [ 0x11 ] = KEY_YELLOW, | ||
136 | [ 0x00 ] = KEY_BLUE, | ||
137 | |||
138 | [ 0x2d ] = KEY_VOLUMEUP, | ||
139 | [ 0x1e ] = KEY_VOLUMEDOWN, | ||
140 | |||
141 | [ 0x49 ] = KEY_MENU, | ||
142 | |||
143 | [ 0x16 ] = KEY_CHANNELUP, | ||
144 | [ 0x17 ] = KEY_CHANNELDOWN, | ||
145 | |||
146 | [ 0x20 ] = KEY_UP, | ||
147 | [ 0x21 ] = KEY_DOWN, | ||
148 | [ 0x22 ] = KEY_LEFT, | ||
149 | [ 0x23 ] = KEY_RIGHT, | ||
150 | [ 0x0d ] = KEY_SELECT, | ||
151 | |||
152 | |||
153 | |||
154 | [ 0x08 ] = KEY_BACK, | ||
155 | [ 0x07 ] = KEY_REFRESH, | ||
156 | |||
157 | [ 0x2f ] = KEY_ZOOM, | ||
158 | [ 0x29 ] = KEY_RECORD, | ||
159 | |||
160 | [ 0x4b ] = KEY_PAUSE, | ||
161 | [ 0x4d ] = KEY_REWIND, | ||
162 | [ 0x2e ] = KEY_PLAY, | ||
163 | [ 0x4e ] = KEY_FORWARD, | ||
164 | [ 0x53 ] = KEY_PREVIOUS, | ||
165 | [ 0x4c ] = KEY_STOP, | ||
166 | [ 0x54 ] = KEY_NEXT, | ||
167 | |||
168 | [ 0x69 ] = KEY_KP0, | ||
169 | [ 0x6a ] = KEY_KP1, | ||
170 | [ 0x6b ] = KEY_KP2, | ||
171 | [ 0x6c ] = KEY_KP3, | ||
172 | [ 0x6d ] = KEY_KP4, | ||
173 | [ 0x6e ] = KEY_KP5, | ||
174 | [ 0x6f ] = KEY_KP6, | ||
175 | [ 0x70 ] = KEY_KP7, | ||
176 | [ 0x71 ] = KEY_KP8, | ||
177 | [ 0x72 ] = KEY_KP9, | ||
178 | |||
179 | [ 0x74 ] = KEY_CHANNEL, | ||
180 | [ 0x0a ] = KEY_BACKSPACE, | ||
181 | }; | ||
182 | |||
183 | /* ----------------------------------------------------------------------- */ | 85 | /* ----------------------------------------------------------------------- */ |
184 | /* insmod parameters */ | 86 | /* insmod parameters */ |
185 | 87 | ||
@@ -281,80 +183,6 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
281 | return 1; | 183 | return 1; |
282 | } | 184 | } |
283 | 185 | ||
284 | static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | ||
285 | { | ||
286 | unsigned char b; | ||
287 | |||
288 | /* poll IR chip */ | ||
289 | if (1 != i2c_master_recv(&ir->c,&b,1)) { | ||
290 | dprintk(1,"read error\n"); | ||
291 | return -EIO; | ||
292 | } | ||
293 | |||
294 | /* no button press */ | ||
295 | if (b==0) | ||
296 | return 0; | ||
297 | |||
298 | /* repeating */ | ||
299 | if (b & 0x80) | ||
300 | return 1; | ||
301 | |||
302 | *ir_key = b; | ||
303 | *ir_raw = b; | ||
304 | return 1; | ||
305 | } | ||
306 | |||
307 | /* The new pinnacle PCTV remote (with the colored buttons) | ||
308 | * | ||
309 | * Ricardo Cerqueira <v4l@cerqueira.org> | ||
310 | */ | ||
311 | |||
312 | static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | ||
313 | { | ||
314 | unsigned char b[4]; | ||
315 | unsigned int start = 0,parity = 0,code = 0; | ||
316 | |||
317 | /* poll IR chip */ | ||
318 | if (4 != i2c_master_recv(&ir->c,b,4)) { | ||
319 | dprintk(1,"read error\n"); | ||
320 | return -EIO; | ||
321 | } | ||
322 | |||
323 | for (start = 0; start<4; start++) { | ||
324 | if (b[start] == 0x80) { | ||
325 | code=b[(start+3)%4]; | ||
326 | parity=b[(start+2)%4]; | ||
327 | } | ||
328 | } | ||
329 | |||
330 | /* Empty Request */ | ||
331 | if (parity==0) | ||
332 | return 0; | ||
333 | |||
334 | /* Repeating... */ | ||
335 | if (ir->old == parity) | ||
336 | return 0; | ||
337 | |||
338 | |||
339 | ir->old = parity; | ||
340 | |||
341 | /* Reduce code value to fit inside IR_KEYTAB_SIZE | ||
342 | * | ||
343 | * this is the only value that results in 42 unique | ||
344 | * codes < 128 | ||
345 | */ | ||
346 | |||
347 | code %= 0x88; | ||
348 | |||
349 | *ir_raw = code; | ||
350 | *ir_key = code; | ||
351 | |||
352 | dprintk(1,"Pinnacle PCTV key %02x\n", code); | ||
353 | |||
354 | return 1; | ||
355 | } | ||
356 | |||
357 | |||
358 | /* ----------------------------------------------------------------------- */ | 186 | /* ----------------------------------------------------------------------- */ |
359 | 187 | ||
360 | static void ir_key_poll(struct IR_i2c *ir) | 188 | static void ir_key_poll(struct IR_i2c *ir) |
@@ -460,19 +288,12 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
460 | ir_type = IR_TYPE_OTHER; | 288 | ir_type = IR_TYPE_OTHER; |
461 | ir_codes = ir_codes_empty; | 289 | ir_codes = ir_codes_empty; |
462 | break; | 290 | break; |
463 | case 0x47: | ||
464 | name = "Pinnacle PCTV"; | ||
465 | ir->get_key = get_key_pinnacle; | ||
466 | ir_type = IR_TYPE_OTHER; | ||
467 | ir_codes = ir_codes_pinnacle; | ||
468 | break; | ||
469 | case 0x7a: | 291 | case 0x7a: |
470 | name = "Purple TV"; | 292 | case 0x47: |
471 | ir->get_key = get_key_purpletv; | 293 | /* Handled by saa7134-input */ |
294 | name = "SAA713x remote"; | ||
472 | ir_type = IR_TYPE_OTHER; | 295 | ir_type = IR_TYPE_OTHER; |
473 | ir_codes = ir_codes_purpletv; | ||
474 | break; | 296 | break; |
475 | |||
476 | default: | 297 | default: |
477 | /* shouldn't happen */ | 298 | /* shouldn't happen */ |
478 | printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n",addr); | 299 | printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n",addr); |
@@ -480,11 +301,8 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
480 | return -1; | 301 | return -1; |
481 | } | 302 | } |
482 | 303 | ||
483 | /* Sets name and its physical addr */ | 304 | /* Sets name */ |
484 | snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name); | 305 | snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name); |
485 | snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0", | ||
486 | ir->c.adapter->dev.bus_id, | ||
487 | ir->c.dev.bus_id); | ||
488 | ir->ir_codes=ir_codes; | 306 | ir->ir_codes=ir_codes; |
489 | 307 | ||
490 | /* register i2c device | 308 | /* register i2c device |
@@ -493,6 +311,18 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
493 | */ | 311 | */ |
494 | i2c_attach_client(&ir->c); | 312 | i2c_attach_client(&ir->c); |
495 | 313 | ||
314 | /* If IR not supported or disabled, unregisters driver */ | ||
315 | if (ir->get_key == NULL) { | ||
316 | i2c_detach_client(&ir->c); | ||
317 | kfree(ir); | ||
318 | return -1; | ||
319 | } | ||
320 | |||
321 | /* Phys addr can only be set after attaching (for ir->c.dev.bus_id) */ | ||
322 | snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0", | ||
323 | ir->c.adapter->dev.bus_id, | ||
324 | ir->c.dev.bus_id); | ||
325 | |||
496 | /* init + register input device */ | 326 | /* init + register input device */ |
497 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); | 327 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
498 | input_dev->id.bustype = BUS_I2C; | 328 | input_dev->id.bustype = BUS_I2C; |
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 2577d03485b8..7575043f0874 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c | |||
@@ -335,6 +335,20 @@ static int attach_inform(struct i2c_client *client) | |||
335 | d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", | 335 | d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", |
336 | client->driver->name, client->addr, client->name); | 336 | client->driver->name, client->addr, client->name); |
337 | 337 | ||
338 | /* Am I an i2c remote control? */ | ||
339 | |||
340 | switch (client->addr) { | ||
341 | case 0x7a: | ||
342 | case 0x47: | ||
343 | { | ||
344 | struct IR_i2c *ir = i2c_get_clientdata(client); | ||
345 | d1printk("%s i2c IR detected (%s).\n", | ||
346 | client->driver->name,ir->phys); | ||
347 | saa7134_set_i2c_ir(dev,ir); | ||
348 | break; | ||
349 | } | ||
350 | } | ||
351 | |||
338 | if (!client->driver->command) | 352 | if (!client->driver->command) |
339 | return 0; | 353 | return 0; |
340 | 354 | ||
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index f99dbb729555..6413a6e09873 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -39,6 +39,8 @@ MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); | |||
39 | 39 | ||
40 | #define dprintk(fmt, arg...) if (ir_debug) \ | 40 | #define dprintk(fmt, arg...) if (ir_debug) \ |
41 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) | 41 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) |
42 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ | ||
43 | printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg) | ||
42 | 44 | ||
43 | /* ---------------------------------------------------------------------- */ | 45 | /* ---------------------------------------------------------------------- */ |
44 | 46 | ||
@@ -443,7 +445,105 @@ static IR_KEYTAB_TYPE gotview7135_codes[IR_KEYTAB_SIZE] = { | |||
443 | [ 112] = KEY_F24, /* NORMAL TIMESHIFT */ | 445 | [ 112] = KEY_F24, /* NORMAL TIMESHIFT */ |
444 | }; | 446 | }; |
445 | 447 | ||
446 | /* ---------------------------------------------------------------------- */ | 448 | static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = { |
449 | [ 0x3 ] = KEY_POWER, | ||
450 | [ 0x6f ] = KEY_MUTE, | ||
451 | [ 0x10 ] = KEY_BACKSPACE, /* Recall */ | ||
452 | |||
453 | [ 0x11 ] = KEY_KP0, | ||
454 | [ 0x4 ] = KEY_KP1, | ||
455 | [ 0x5 ] = KEY_KP2, | ||
456 | [ 0x6 ] = KEY_KP3, | ||
457 | [ 0x8 ] = KEY_KP4, | ||
458 | [ 0x9 ] = KEY_KP5, | ||
459 | [ 0xa ] = KEY_KP6, | ||
460 | [ 0xc ] = KEY_KP7, | ||
461 | [ 0xd ] = KEY_KP8, | ||
462 | [ 0xe ] = KEY_KP9, | ||
463 | [ 0x12 ] = KEY_KPDOT, /* 100+ */ | ||
464 | |||
465 | [ 0x7 ] = KEY_VOLUMEUP, | ||
466 | [ 0xb ] = KEY_VOLUMEDOWN, | ||
467 | [ 0x1a ] = KEY_KPPLUS, | ||
468 | [ 0x18 ] = KEY_KPMINUS, | ||
469 | [ 0x15 ] = KEY_UP, | ||
470 | [ 0x1d ] = KEY_DOWN, | ||
471 | [ 0xf ] = KEY_CHANNELUP, | ||
472 | [ 0x13 ] = KEY_CHANNELDOWN, | ||
473 | [ 0x48 ] = KEY_ZOOM, | ||
474 | |||
475 | [ 0x1b ] = KEY_VIDEO, /* Video source */ | ||
476 | [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */ | ||
477 | [ 0x19 ] = KEY_SEARCH, /* Auto Scan */ | ||
478 | |||
479 | [ 0x4b ] = KEY_RECORD, | ||
480 | [ 0x46 ] = KEY_PLAY, | ||
481 | [ 0x45 ] = KEY_PAUSE, /* Pause */ | ||
482 | [ 0x44 ] = KEY_STOP, | ||
483 | [ 0x40 ] = KEY_FORWARD, /* Forward ? */ | ||
484 | [ 0x42 ] = KEY_REWIND, /* Backward ? */ | ||
485 | |||
486 | }; | ||
487 | |||
488 | static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = { | ||
489 | [ 0x59 ] = KEY_MUTE, | ||
490 | [ 0x4a ] = KEY_POWER, | ||
491 | |||
492 | [ 0x18 ] = KEY_TEXT, | ||
493 | [ 0x26 ] = KEY_TV, | ||
494 | [ 0x3d ] = KEY_PRINT, | ||
495 | |||
496 | [ 0x48 ] = KEY_RED, | ||
497 | [ 0x04 ] = KEY_GREEN, | ||
498 | [ 0x11 ] = KEY_YELLOW, | ||
499 | [ 0x00 ] = KEY_BLUE, | ||
500 | |||
501 | [ 0x2d ] = KEY_VOLUMEUP, | ||
502 | [ 0x1e ] = KEY_VOLUMEDOWN, | ||
503 | |||
504 | [ 0x49 ] = KEY_MENU, | ||
505 | |||
506 | [ 0x16 ] = KEY_CHANNELUP, | ||
507 | [ 0x17 ] = KEY_CHANNELDOWN, | ||
508 | |||
509 | [ 0x20 ] = KEY_UP, | ||
510 | [ 0x21 ] = KEY_DOWN, | ||
511 | [ 0x22 ] = KEY_LEFT, | ||
512 | [ 0x23 ] = KEY_RIGHT, | ||
513 | [ 0x0d ] = KEY_SELECT, | ||
514 | |||
515 | |||
516 | |||
517 | [ 0x08 ] = KEY_BACK, | ||
518 | [ 0x07 ] = KEY_REFRESH, | ||
519 | |||
520 | [ 0x2f ] = KEY_ZOOM, | ||
521 | [ 0x29 ] = KEY_RECORD, | ||
522 | |||
523 | [ 0x4b ] = KEY_PAUSE, | ||
524 | [ 0x4d ] = KEY_REWIND, | ||
525 | [ 0x2e ] = KEY_PLAY, | ||
526 | [ 0x4e ] = KEY_FORWARD, | ||
527 | [ 0x53 ] = KEY_PREVIOUS, | ||
528 | [ 0x4c ] = KEY_STOP, | ||
529 | [ 0x54 ] = KEY_NEXT, | ||
530 | |||
531 | [ 0x69 ] = KEY_KP0, | ||
532 | [ 0x6a ] = KEY_KP1, | ||
533 | [ 0x6b ] = KEY_KP2, | ||
534 | [ 0x6c ] = KEY_KP3, | ||
535 | [ 0x6d ] = KEY_KP4, | ||
536 | [ 0x6e ] = KEY_KP5, | ||
537 | [ 0x6f ] = KEY_KP6, | ||
538 | [ 0x70 ] = KEY_KP7, | ||
539 | [ 0x71 ] = KEY_KP8, | ||
540 | [ 0x72 ] = KEY_KP9, | ||
541 | |||
542 | [ 0x74 ] = KEY_CHANNEL, | ||
543 | [ 0x0a ] = KEY_BACKSPACE, | ||
544 | }; | ||
545 | |||
546 | /* -------------------- GPIO generic keycode builder -------------------- */ | ||
447 | 547 | ||
448 | static int build_key(struct saa7134_dev *dev) | 548 | static int build_key(struct saa7134_dev *dev) |
449 | { | 549 | { |
@@ -474,7 +574,81 @@ static int build_key(struct saa7134_dev *dev) | |||
474 | return 0; | 574 | return 0; |
475 | } | 575 | } |
476 | 576 | ||
477 | /* ---------------------------------------------------------------------- */ | 577 | /* --------------------- Chip specific I2C key builders ----------------- */ |
578 | |||
579 | static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | ||
580 | { | ||
581 | unsigned char b; | ||
582 | |||
583 | /* poll IR chip */ | ||
584 | if (1 != i2c_master_recv(&ir->c,&b,1)) { | ||
585 | i2cdprintk("read error\n"); | ||
586 | return -EIO; | ||
587 | } | ||
588 | |||
589 | /* no button press */ | ||
590 | if (b==0) | ||
591 | return 0; | ||
592 | |||
593 | /* repeating */ | ||
594 | if (b & 0x80) | ||
595 | return 1; | ||
596 | |||
597 | *ir_key = b; | ||
598 | *ir_raw = b; | ||
599 | return 1; | ||
600 | } | ||
601 | |||
602 | /* The new pinnacle PCTV remote (with the colored buttons) | ||
603 | * | ||
604 | * Ricardo Cerqueira <v4l@cerqueira.org> | ||
605 | */ | ||
606 | |||
607 | static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | ||
608 | { | ||
609 | unsigned char b[4]; | ||
610 | unsigned int start = 0,parity = 0,code = 0; | ||
611 | |||
612 | /* poll IR chip */ | ||
613 | if (4 != i2c_master_recv(&ir->c,b,4)) { | ||
614 | i2cdprintk("read error\n"); | ||
615 | return -EIO; | ||
616 | } | ||
617 | |||
618 | for (start = 0; start<4; start++) { | ||
619 | if (b[start] == 0x80) { | ||
620 | code=b[(start+3)%4]; | ||
621 | parity=b[(start+2)%4]; | ||
622 | } | ||
623 | } | ||
624 | |||
625 | /* Empty Request */ | ||
626 | if (parity==0) | ||
627 | return 0; | ||
628 | |||
629 | /* Repeating... */ | ||
630 | if (ir->old == parity) | ||
631 | return 0; | ||
632 | |||
633 | |||
634 | ir->old = parity; | ||
635 | |||
636 | /* Reduce code value to fit inside IR_KEYTAB_SIZE | ||
637 | * | ||
638 | * this is the only value that results in 42 unique | ||
639 | * codes < 128 | ||
640 | */ | ||
641 | |||
642 | code %= 0x88; | ||
643 | |||
644 | *ir_raw = code; | ||
645 | *ir_key = code; | ||
646 | |||
647 | i2cdprintk("Pinnacle PCTV key %02x\n", code); | ||
648 | |||
649 | return 1; | ||
650 | } | ||
651 | |||
478 | 652 | ||
479 | void saa7134_input_irq(struct saa7134_dev *dev) | 653 | void saa7134_input_irq(struct saa7134_dev *dev) |
480 | { | 654 | { |
@@ -658,6 +832,30 @@ void saa7134_input_fini(struct saa7134_dev *dev) | |||
658 | dev->remote = NULL; | 832 | dev->remote = NULL; |
659 | } | 833 | } |
660 | 834 | ||
835 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir) | ||
836 | { | ||
837 | if (disable_ir) { | ||
838 | ir->get_key=NULL; | ||
839 | return; | ||
840 | } | ||
841 | |||
842 | switch (dev->board) { | ||
843 | case SAA7134_BOARD_PINNACLE_PCTV_110i: | ||
844 | snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV"); | ||
845 | ir->get_key = get_key_pinnacle; | ||
846 | ir->ir_codes = ir_codes_pinnacle; | ||
847 | break; | ||
848 | case SAA7134_BOARD_UPMOST_PURPLE_TV: | ||
849 | snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV"); | ||
850 | ir->get_key = get_key_purpletv; | ||
851 | ir->ir_codes = ir_codes_purpletv; | ||
852 | break; | ||
853 | default: | ||
854 | dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board); | ||
855 | break; | ||
856 | } | ||
857 | |||
858 | } | ||
661 | /* ---------------------------------------------------------------------- | 859 | /* ---------------------------------------------------------------------- |
662 | * Local variables: | 860 | * Local variables: |
663 | * c-basic-offset: 8 | 861 | * c-basic-offset: 8 |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index d497fea5425f..99d000be095e 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <media/audiochip.h> | 36 | #include <media/audiochip.h> |
37 | #include <media/id.h> | 37 | #include <media/id.h> |
38 | #include <media/ir-common.h> | 38 | #include <media/ir-common.h> |
39 | #include <media/ir-kbd-i2c.h> | ||
39 | #include <media/video-buf.h> | 40 | #include <media/video-buf.h> |
40 | #include <media/video-buf-dvb.h> | 41 | #include <media/video-buf-dvb.h> |
41 | 42 | ||
@@ -653,6 +654,10 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status); | |||
653 | int saa7134_input_init1(struct saa7134_dev *dev); | 654 | int saa7134_input_init1(struct saa7134_dev *dev); |
654 | void saa7134_input_fini(struct saa7134_dev *dev); | 655 | void saa7134_input_fini(struct saa7134_dev *dev); |
655 | void saa7134_input_irq(struct saa7134_dev *dev); | 656 | void saa7134_input_irq(struct saa7134_dev *dev); |
657 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); | ||
658 | |||
659 | /* ----------------------------------------------------------- */ | ||
660 | /* saa7134-alsa.c */ | ||
656 | 661 | ||
657 | int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devnum); | 662 | int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devnum); |
658 | void alsa_card_saa7134_exit(void); | 663 | void alsa_card_saa7134_exit(void); |