aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 21:24:50 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-15 21:18:07 -0500
commitb779974bdfcaec2a0eb13e44405baca07e0e92a3 (patch)
tree0cd6a73d51fed57271396f6dc0522ddf64bbd4cd
parentb33f5f8af3fabe6a080c9d06f8f3184a4de3f3c2 (diff)
V4L/DVB (13575): em28xx: Use the complete address/command RC5 code for WinTV USB2
This device uses an i2c chip to retrieve the keycode from a RC5 remote. Instead of just getting 6 bits, improve the routine to get 11 bits. This means that the complete RC5 table for Hauppauge Grey IR can be used with this device. Unfortunately, it seems that this IR receiver is not capable of getting the full 14 (or 13 bits) from the RC5 protocol. At lest now, with the new code, it is possible to replace this IR table by another RC5 table. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c41
2 files changed, 30 insertions, 13 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index e7a68e2507de..25100001ffff 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -2285,7 +2285,7 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
2285 dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)"; 2285 dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
2286 break; 2286 break;
2287 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: 2287 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2288 dev->init_data.ir_codes = &ir_codes_hauppauge_new_table; 2288 dev->init_data.ir_codes = &ir_codes_rc5_hauppauge_new_table;
2289 dev->init_data.get_key = em28xx_get_key_em_haup; 2289 dev->init_data.get_key = em28xx_get_key_em_haup;
2290 dev->init_data.name = "i2c IR (EM2840 Hauppauge)"; 2290 dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
2291 break; 2291 break;
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 3f5cf02f3147..5ddeb421ed58 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -112,10 +112,13 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
112int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) 112int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
113{ 113{
114 unsigned char buf[2]; 114 unsigned char buf[2];
115 unsigned char code; 115 u16 code;
116 int size;
116 117
117 /* poll IR chip */ 118 /* poll IR chip */
118 if (2 != i2c_master_recv(ir->c, buf, 2)) 119 size = i2c_master_recv(ir->c, buf, sizeof(buf));
120
121 if (size != 2)
119 return -EIO; 122 return -EIO;
120 123
121 /* Does eliminate repeated parity code */ 124 /* Does eliminate repeated parity code */
@@ -124,16 +127,30 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
124 127
125 ir->old = buf[1]; 128 ir->old = buf[1];
126 129
127 /* Rearranges bits to the right order */ 130 /*
128 code = ((buf[0]&0x01)<<5) | /* 0010 0000 */ 131 * Rearranges bits to the right order.
129 ((buf[0]&0x02)<<3) | /* 0001 0000 */ 132 * The bit order were determined experimentally by using
130 ((buf[0]&0x04)<<1) | /* 0000 1000 */ 133 * The original Hauppauge Grey IR and another RC5 that uses addr=0x08
131 ((buf[0]&0x08)>>1) | /* 0000 0100 */ 134 * The RC5 code has 14 bits, but we've experimentally determined
132 ((buf[0]&0x10)>>3) | /* 0000 0010 */ 135 * the meaning for only 11 bits.
133 ((buf[0]&0x20)>>5); /* 0000 0001 */ 136 * So, the code translation is not complete. Yet, it is enough to
134 137 * work with the provided RC5 IR.
135 i2cdprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n", 138 */
136 code, buf[0]); 139 code =
140 ((buf[0] & 0x01) ? 0x0020 : 0) | /* 0010 0000 */
141 ((buf[0] & 0x02) ? 0x0010 : 0) | /* 0001 0000 */
142 ((buf[0] & 0x04) ? 0x0008 : 0) | /* 0000 1000 */
143 ((buf[0] & 0x08) ? 0x0004 : 0) | /* 0000 0100 */
144 ((buf[0] & 0x10) ? 0x0002 : 0) | /* 0000 0010 */
145 ((buf[0] & 0x20) ? 0x0001 : 0) | /* 0000 0001 */
146 ((buf[1] & 0x08) ? 0x1000 : 0) | /* 0001 0000 */
147 ((buf[1] & 0x10) ? 0x0800 : 0) | /* 0000 1000 */
148 ((buf[1] & 0x20) ? 0x0400 : 0) | /* 0000 0100 */
149 ((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010 */
150 ((buf[1] & 0x80) ? 0x0100 : 0); /* 0000 0001 */
151
152 i2cdprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x%02x)\n",
153 code, buf[1], buf[0]);
137 154
138 /* return key */ 155 /* return key */
139 *ir_key = code; 156 *ir_key = code;