diff options
Diffstat (limited to 'drivers/media/i2c/ir-kbd-i2c.c')
| -rw-r--r-- | drivers/media/i2c/ir-kbd-i2c.c | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index c8fe1358ec9e..8311f1a9a38e 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c | |||
| @@ -62,8 +62,8 @@ module_param(debug, int, 0644); /* debug level (0,1,2) */ | |||
| 62 | 62 | ||
| 63 | /* ----------------------------------------------------------------------- */ | 63 | /* ----------------------------------------------------------------------- */ |
| 64 | 64 | ||
| 65 | static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, | 65 | static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol, |
| 66 | int size, int offset) | 66 | u32 *scancode, u8 *ptoggle, int size, int offset) |
| 67 | { | 67 | { |
| 68 | unsigned char buf[6]; | 68 | unsigned char buf[6]; |
| 69 | int start, range, toggle, dev, code, ircode; | 69 | int start, range, toggle, dev, code, ircode; |
| @@ -86,19 +86,10 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, | |||
| 86 | if (!start) | 86 | if (!start) |
| 87 | /* no key pressed */ | 87 | /* no key pressed */ |
| 88 | return 0; | 88 | return 0; |
| 89 | /* | 89 | |
| 90 | * Hauppauge remotes (black/silver) always use | 90 | /* filter out invalid key presses */ |
| 91 | * specific device ids. If we do not filter the | 91 | ircode = (start << 12) | (toggle << 11) | (dev << 6) | code; |
| 92 | * device ids then messages destined for devices | 92 | if ((ircode & 0x1fff) == 0x1fff) |
| 93 | * such as TVs (id=0) will get through causing | ||
| 94 | * mis-fired events. | ||
| 95 | * | ||
| 96 | * We also filter out invalid key presses which | ||
| 97 | * produce annoying debug log entries. | ||
| 98 | */ | ||
| 99 | ircode= (start << 12) | (toggle << 11) | (dev << 6) | code; | ||
| 100 | if ((ircode & 0x1fff)==0x1fff) | ||
| 101 | /* invalid key press */ | ||
| 102 | return 0; | 93 | return 0; |
| 103 | 94 | ||
| 104 | if (!range) | 95 | if (!range) |
| @@ -107,18 +98,20 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, | |||
| 107 | dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", | 98 | dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", |
| 108 | start, range, toggle, dev, code); | 99 | start, range, toggle, dev, code); |
| 109 | 100 | ||
| 110 | /* return key */ | 101 | *protocol = RC_TYPE_RC5; |
| 111 | *ir_key = (dev << 8) | code; | 102 | *scancode = RC_SCANCODE_RC5(dev, code); |
| 112 | *ir_raw = ircode; | 103 | *ptoggle = toggle; |
| 113 | return 1; | 104 | return 1; |
| 114 | } | 105 | } |
| 115 | 106 | ||
| 116 | static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 107 | static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol, |
| 108 | u32 *scancode, u8 *toggle) | ||
| 117 | { | 109 | { |
| 118 | return get_key_haup_common (ir, ir_key, ir_raw, 3, 0); | 110 | return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0); |
| 119 | } | 111 | } |
| 120 | 112 | ||
| 121 | static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 113 | static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol, |
| 114 | u32 *scancode, u8 *toggle) | ||
| 122 | { | 115 | { |
| 123 | int ret; | 116 | int ret; |
| 124 | unsigned char buf[1] = { 0 }; | 117 | unsigned char buf[1] = { 0 }; |
| @@ -133,10 +126,11 @@ static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 133 | if (ret != 1) | 126 | if (ret != 1) |
| 134 | return (ret < 0) ? ret : -EINVAL; | 127 | return (ret < 0) ? ret : -EINVAL; |
| 135 | 128 | ||
| 136 | return get_key_haup_common (ir, ir_key, ir_raw, 6, 3); | 129 | return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3); |
| 137 | } | 130 | } |
| 138 | 131 | ||
| 139 | static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 132 | static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol, |
| 133 | u32 *scancode, u8 *toggle) | ||
| 140 | { | 134 | { |
| 141 | unsigned char b; | 135 | unsigned char b; |
| 142 | 136 | ||
| @@ -145,12 +139,15 @@ static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 145 | dprintk(1,"read error\n"); | 139 | dprintk(1,"read error\n"); |
| 146 | return -EIO; | 140 | return -EIO; |
| 147 | } | 141 | } |
| 148 | *ir_key = b; | 142 | |
| 149 | *ir_raw = b; | 143 | *protocol = RC_TYPE_OTHER; |
| 144 | *scancode = b; | ||
| 145 | *toggle = 0; | ||
| 150 | return 1; | 146 | return 1; |
| 151 | } | 147 | } |
| 152 | 148 | ||
| 153 | static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 149 | static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol, |
| 150 | u32 *scancode, u8 *toggle) | ||
| 154 | { | 151 | { |
| 155 | unsigned char buf[4]; | 152 | unsigned char buf[4]; |
| 156 | 153 | ||
| @@ -168,13 +165,14 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 168 | if(buf[0] != 0x1 || buf[1] != 0xfe) | 165 | if(buf[0] != 0x1 || buf[1] != 0xfe) |
| 169 | return 0; | 166 | return 0; |
| 170 | 167 | ||
| 171 | *ir_key = buf[2]; | 168 | *protocol = RC_TYPE_UNKNOWN; |
| 172 | *ir_raw = (buf[2] << 8) | buf[3]; | 169 | *scancode = buf[2]; |
| 173 | 170 | *toggle = 0; | |
| 174 | return 1; | 171 | return 1; |
| 175 | } | 172 | } |
| 176 | 173 | ||
| 177 | static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 174 | static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol, |
| 175 | u32 *scancode, u8 *toggle) | ||
| 178 | { | 176 | { |
| 179 | unsigned char b; | 177 | unsigned char b; |
| 180 | 178 | ||
| @@ -197,13 +195,14 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 197 | /* keep old data */ | 195 | /* keep old data */ |
| 198 | return 1; | 196 | return 1; |
| 199 | 197 | ||
| 200 | *ir_key = b; | 198 | *protocol = RC_TYPE_UNKNOWN; |
| 201 | *ir_raw = b; | 199 | *scancode = b; |
| 200 | *toggle = 0; | ||
| 202 | return 1; | 201 | return 1; |
| 203 | } | 202 | } |
| 204 | 203 | ||
| 205 | static int get_key_avermedia_cardbus(struct IR_i2c *ir, | 204 | static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol, |
| 206 | u32 *ir_key, u32 *ir_raw) | 205 | u32 *scancode, u8 *toggle) |
| 207 | { | 206 | { |
| 208 | unsigned char subaddr, key, keygroup; | 207 | unsigned char subaddr, key, keygroup; |
| 209 | struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, | 208 | struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, |
| @@ -237,12 +236,11 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, | |||
| 237 | } | 236 | } |
| 238 | key |= (keygroup & 1) << 6; | 237 | key |= (keygroup & 1) << 6; |
| 239 | 238 | ||
| 240 | *ir_key = key; | 239 | *protocol = RC_TYPE_UNKNOWN; |
| 241 | *ir_raw = key; | 240 | *scancode = key; |
| 242 | if (!strcmp(ir->ir_codes, RC_MAP_AVERMEDIA_M733A_RM_K6)) { | 241 | if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ |
| 243 | *ir_key |= keygroup << 8; | 242 | *scancode |= keygroup << 8; |
| 244 | *ir_raw |= keygroup << 8; | 243 | *toggle = 0; |
| 245 | } | ||
| 246 | return 1; | 244 | return 1; |
| 247 | } | 245 | } |
| 248 | 246 | ||
| @@ -250,19 +248,22 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, | |||
| 250 | 248 | ||
| 251 | static int ir_key_poll(struct IR_i2c *ir) | 249 | static int ir_key_poll(struct IR_i2c *ir) |
| 252 | { | 250 | { |
| 253 | static u32 ir_key, ir_raw; | 251 | enum rc_type protocol; |
| 252 | u32 scancode; | ||
| 253 | u8 toggle; | ||
| 254 | int rc; | 254 | int rc; |
| 255 | 255 | ||
| 256 | dprintk(3, "%s\n", __func__); | 256 | dprintk(3, "%s\n", __func__); |
| 257 | rc = ir->get_key(ir, &ir_key, &ir_raw); | 257 | rc = ir->get_key(ir, &protocol, &scancode, &toggle); |
| 258 | if (rc < 0) { | 258 | if (rc < 0) { |
| 259 | dprintk(2,"error\n"); | 259 | dprintk(2,"error\n"); |
| 260 | return rc; | 260 | return rc; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | if (rc) { | 263 | if (rc) { |
| 264 | dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key); | 264 | dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n", |
| 265 | rc_keydown(ir->rc, ir_key, 0); | 265 | __func__, protocol, scancode); |
| 266 | rc_keydown(ir->rc, protocol, scancode, toggle); | ||
| 266 | } | 267 | } |
| 267 | return 0; | 268 | return 0; |
| 268 | } | 269 | } |
| @@ -327,7 +328,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
| 327 | case 0x6b: | 328 | case 0x6b: |
| 328 | name = "FusionHDTV"; | 329 | name = "FusionHDTV"; |
| 329 | ir->get_key = get_key_fusionhdtv; | 330 | ir->get_key = get_key_fusionhdtv; |
| 330 | rc_type = RC_BIT_RC5; | 331 | rc_type = RC_BIT_UNKNOWN; |
| 331 | ir_codes = RC_MAP_FUSIONHDTV_MCE; | 332 | ir_codes = RC_MAP_FUSIONHDTV_MCE; |
| 332 | break; | 333 | break; |
| 333 | case 0x40: | 334 | case 0x40: |
| @@ -431,8 +432,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
| 431 | * Initialize the other fields of rc_dev | 432 | * Initialize the other fields of rc_dev |
| 432 | */ | 433 | */ |
| 433 | rc->map_name = ir->ir_codes; | 434 | rc->map_name = ir->ir_codes; |
| 434 | rc_set_allowed_protocols(rc, rc_type); | 435 | rc->allowed_protocols = rc_type; |
| 435 | rc_set_enabled_protocols(rc, rc_type); | 436 | rc->enabled_protocols = rc_type; |
| 436 | if (!rc->driver_name) | 437 | if (!rc->driver_name) |
| 437 | rc->driver_name = MODULE_NAME; | 438 | rc->driver_name = MODULE_NAME; |
| 438 | 439 | ||
