[media] rc-core: improve ir-kbd-i2c get_key functions
The arguments used for ir-kbd-i2c's get_key() functions are not really suited for rc-core and the ir_raw/ir_key distinction is just confusing. Convert all of them to return a protocol/scancode/toggle triple instead. Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Tento commit je obsažen v:

odevzdal
Mauro Carvalho Chehab

rodič
2886f013c3
revize
4dd9bb91bb
@@ -62,8 +62,8 @@ module_param(debug, int, 0644); /* debug level (0,1,2) */
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
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 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
|
||||
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 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
|
||||
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 @@ static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
||||
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 @@ static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
||||
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 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
||||
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 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
||||
/* 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 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
|
||||
}
|
||||
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,21 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
|
||||
|
||||
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: scancode = 0x%08x\n", __func__, scancode);
|
||||
rc_keydown(ir->rc, scancode, toggle);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
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:
|
||||
|
Odkázat v novém úkolu
Zablokovat Uživatele