--- zzzz-none-000/linux-3.10.107/drivers/media/i2c/ir-kbd-i2c.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/i2c/ir-kbd-i2c.c 2021-02-04 17:41:59.000000000 +0000 @@ -62,8 +62,8 @@ /* ----------------------------------------------------------------------- */ -static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, - int size, int offset) +static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *ptoggle, int size, int offset) { unsigned char buf[6]; int start, range, toggle, dev, code, ircode; @@ -86,19 +86,10 @@ if (!start) /* no key pressed */ return 0; - /* - * Hauppauge remotes (black/silver) always use - * specific device ids. If we do not filter the - * device ids then messages destined for devices - * such as TVs (id=0) will get through causing - * mis-fired events. - * - * We also filter out invalid key presses which - * produce annoying debug log entries. - */ - ircode= (start << 12) | (toggle << 11) | (dev << 6) | code; - if ((ircode & 0x1fff)==0x1fff) - /* invalid key press */ + + /* filter out invalid key presses */ + ircode = (start << 12) | (toggle << 11) | (dev << 6) | code; + if ((ircode & 0x1fff) == 0x1fff) return 0; if (!range) @@ -107,18 +98,20 @@ dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", start, range, toggle, dev, code); - /* return key */ - *ir_key = (dev << 8) | code; - *ir_raw = ircode; + *protocol = RC_TYPE_RC5; + *scancode = RC_SCANCODE_RC5(dev, code); + *ptoggle = toggle; return 1; } -static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { - return get_key_haup_common (ir, ir_key, ir_raw, 3, 0); + return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0); } -static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { int ret; unsigned char buf[1] = { 0 }; @@ -133,10 +126,11 @@ if (ret != 1) return (ret < 0) ? ret : -EINVAL; - return get_key_haup_common (ir, ir_key, ir_raw, 6, 3); + return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3); } -static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char b; @@ -145,12 +139,15 @@ dprintk(1,"read error\n"); return -EIO; } - *ir_key = b; - *ir_raw = b; + + *protocol = RC_TYPE_OTHER; + *scancode = b; + *toggle = 0; return 1; } -static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char buf[4]; @@ -168,13 +165,14 @@ if(buf[0] != 0x1 || buf[1] != 0xfe) return 0; - *ir_key = buf[2]; - *ir_raw = (buf[2] << 8) | buf[3]; - + *protocol = RC_TYPE_UNKNOWN; + *scancode = buf[2]; + *toggle = 0; return 1; } -static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) +static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char b; @@ -197,13 +195,14 @@ /* keep old data */ return 1; - *ir_key = b; - *ir_raw = b; + *protocol = RC_TYPE_UNKNOWN; + *scancode = b; + *toggle = 0; return 1; } -static int get_key_avermedia_cardbus(struct IR_i2c *ir, - u32 *ir_key, u32 *ir_raw) +static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol, + u32 *scancode, u8 *toggle) { unsigned char subaddr, key, keygroup; struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, @@ -237,12 +236,11 @@ } key |= (keygroup & 1) << 6; - *ir_key = key; - *ir_raw = key; - if (!strcmp(ir->ir_codes, RC_MAP_AVERMEDIA_M733A_RM_K6)) { - *ir_key |= keygroup << 8; - *ir_raw |= keygroup << 8; - } + *protocol = RC_TYPE_UNKNOWN; + *scancode = key; + if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ + *scancode |= keygroup << 8; + *toggle = 0; return 1; } @@ -250,19 +248,22 @@ static int ir_key_poll(struct IR_i2c *ir) { - static u32 ir_key, ir_raw; + enum rc_type protocol; + u32 scancode; + u8 toggle; int rc; dprintk(3, "%s\n", __func__); - rc = ir->get_key(ir, &ir_key, &ir_raw); + rc = ir->get_key(ir, &protocol, &scancode, &toggle); if (rc < 0) { dprintk(2,"error\n"); return rc; } if (rc) { - dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key); - rc_keydown(ir->rc, ir_key, 0); + dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n", + __func__, protocol, scancode); + rc_keydown(ir->rc, protocol, scancode, toggle); } return 0; } @@ -295,7 +296,7 @@ unsigned short addr = client->addr; int err; - ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); + ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); if (!ir) return -ENOMEM; @@ -327,7 +328,7 @@ case 0x6b: name = "FusionHDTV"; ir->get_key = get_key_fusionhdtv; - rc_type = RC_BIT_RC5; + rc_type = RC_BIT_UNKNOWN; ir_codes = RC_MAP_FUSIONHDTV_MCE; break; case 0x40: @@ -394,14 +395,12 @@ if (!rc) { /* - * If platform_data doesn't specify rc_dev, initilize it + * If platform_data doesn't specify rc_dev, initialize it * internally */ rc = rc_allocate_device(); - if (!rc) { - err = -ENOMEM; - goto err_out_free; - } + if (!rc) + return -ENOMEM; } ir->rc = rc; @@ -433,7 +432,7 @@ * Initialize the other fields of rc_dev */ rc->map_name = ir->ir_codes; - rc->allowed_protos = rc_type; + rc->allowed_protocols = rc_type; rc->enabled_protocols = rc_type; if (!rc->driver_name) rc->driver_name = MODULE_NAME; @@ -454,7 +453,6 @@ err_out_free: /* Only frees rc if it were allocated internally */ rc_free_device(rc); - kfree(ir); return err; } @@ -466,11 +464,9 @@ cancel_delayed_work_sync(&ir->work); /* unregister device */ - if (ir->rc) - rc_unregister_device(ir->rc); + rc_unregister_device(ir->rc); /* free memory */ - kfree(ir); return 0; }