diff options
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r-- | drivers/media/video/ir-kbd-i2c.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index d4658c56eddc..2ee49b7ddcf0 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * Henry Wong <henry@stuffedcow.net> | 16 | * Henry Wong <henry@stuffedcow.net> |
17 | * Mark Schultz <n9xmj@yahoo.com> | 17 | * Mark Schultz <n9xmj@yahoo.com> |
18 | * Brian Rogers <brian_rogers@comcast.net> | 18 | * Brian Rogers <brian_rogers@comcast.net> |
19 | * modified for AVerMedia Cardbus by | ||
20 | * Oldrich Jedlicka <oldium.pro@seznam.cz> | ||
19 | * | 21 | * |
20 | * This program is free software; you can redistribute it and/or modify | 22 | * This program is free software; you can redistribute it and/or modify |
21 | * it under the terms of the GNU General Public License as published by | 23 | * it under the terms of the GNU General Public License as published by |
@@ -216,6 +218,46 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
216 | return 1; | 218 | return 1; |
217 | } | 219 | } |
218 | 220 | ||
221 | static int get_key_avermedia_cardbus(struct IR_i2c *ir, | ||
222 | u32 *ir_key, u32 *ir_raw) | ||
223 | { | ||
224 | unsigned char subaddr, key, keygroup; | ||
225 | struct i2c_msg msg[] = { { .addr = ir->c.addr, .flags = 0, | ||
226 | .buf = &subaddr, .len = 1}, | ||
227 | { .addr = ir->c.addr, .flags = I2C_M_RD, | ||
228 | .buf = &key, .len = 1} }; | ||
229 | subaddr = 0x0d; | ||
230 | if (2 != i2c_transfer(ir->c.adapter, msg, 2)) { | ||
231 | dprintk(1, "read error\n"); | ||
232 | return -EIO; | ||
233 | } | ||
234 | |||
235 | if (key == 0xff) | ||
236 | return 0; | ||
237 | |||
238 | subaddr = 0x0b; | ||
239 | msg[1].buf = &keygroup; | ||
240 | if (2 != i2c_transfer(ir->c.adapter, msg, 2)) { | ||
241 | dprintk(1, "read error\n"); | ||
242 | return -EIO; | ||
243 | } | ||
244 | |||
245 | if (keygroup == 0xff) | ||
246 | return 0; | ||
247 | |||
248 | dprintk(1, "read key 0x%02x/0x%02x\n", key, keygroup); | ||
249 | if (keygroup < 2 || keygroup > 3) { | ||
250 | /* Only a warning */ | ||
251 | dprintk(1, "warning: invalid key group 0x%02x for key 0x%02x\n", | ||
252 | keygroup, key); | ||
253 | } | ||
254 | key |= (keygroup & 1) << 6; | ||
255 | |||
256 | *ir_key = key; | ||
257 | *ir_raw = key; | ||
258 | return 1; | ||
259 | } | ||
260 | |||
219 | /* ----------------------------------------------------------------------- */ | 261 | /* ----------------------------------------------------------------------- */ |
220 | 262 | ||
221 | static void ir_key_poll(struct IR_i2c *ir) | 263 | static void ir_key_poll(struct IR_i2c *ir) |
@@ -360,6 +402,12 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
360 | ir_type = IR_TYPE_OTHER; | 402 | ir_type = IR_TYPE_OTHER; |
361 | } | 403 | } |
362 | break; | 404 | break; |
405 | case 0x40: | ||
406 | name = "AVerMedia Cardbus remote"; | ||
407 | ir->get_key = get_key_avermedia_cardbus; | ||
408 | ir_type = IR_TYPE_OTHER; | ||
409 | ir_codes = ir_codes_avermedia_cardbus; | ||
410 | break; | ||
363 | default: | 411 | default: |
364 | /* shouldn't happen */ | 412 | /* shouldn't happen */ |
365 | printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n", addr); | 413 | printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n", addr); |
@@ -524,6 +572,22 @@ static int ir_probe(struct i2c_adapter *adap) | |||
524 | ir_attach(adap, msg.addr, 0, 0); | 572 | ir_attach(adap, msg.addr, 0, 0); |
525 | } | 573 | } |
526 | 574 | ||
575 | /* Special case for AVerMedia Cardbus remote */ | ||
576 | if (adap->id == I2C_HW_SAA7134) { | ||
577 | unsigned char subaddr, data; | ||
578 | struct i2c_msg msg[] = { { .addr = 0x40, .flags = 0, | ||
579 | .buf = &subaddr, .len = 1}, | ||
580 | { .addr = 0x40, .flags = I2C_M_RD, | ||
581 | .buf = &data, .len = 1} }; | ||
582 | subaddr = 0x0d; | ||
583 | rc = i2c_transfer(adap, msg, 2); | ||
584 | dprintk(1, "probe 0x%02x/0x%02x @ %s: %s\n", | ||
585 | msg[0].addr, subaddr, adap->name, | ||
586 | (2 == rc) ? "yes" : "no"); | ||
587 | if (2 == rc) | ||
588 | ir_attach(adap, msg[0].addr, 0, 0); | ||
589 | } | ||
590 | |||
527 | return 0; | 591 | return 0; |
528 | } | 592 | } |
529 | 593 | ||