Commit f526e9e1 authored by Antonio Ospite's avatar Antonio Ospite Committed by Mauro Carvalho Chehab

[media] m920x: factor out a m920x_parse_rc_state() function

This is in preparation to using RC core infrastructure for some devices,
the RC button state parsing logic can be shared berween rc.legacy and
rc.core callbacks as it is independent from the mechanism used for RC
handling.
Signed-off-by: default avatarAntonio Ospite <ospite@studenti.unina.it>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7543f344
......@@ -140,30 +140,15 @@ static int m920x_init_ep(struct usb_interface *intf)
alt->desc.bAlternateSetting);
}
static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
static inline void m920x_parse_rc_state(struct dvb_usb_device *d, u8 rc_state,
int *state)
{
struct m920x_state *m = d->priv;
int i, ret = 0;
u8 *rc_state;
rc_state = kmalloc(2, GFP_KERNEL);
if (!rc_state)
return -ENOMEM;
if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
goto out;
if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
goto out;
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
if (rc5_data(&d->props.rc.legacy.rc_map_table[i]) == rc_state[1]) {
*event = d->props.rc.legacy.rc_map_table[i].keycode;
switch(rc_state[0]) {
switch (rc_state) {
case 0x80:
*state = REMOTE_NO_KEY_PRESSED;
goto out;
break;
case 0x88: /* framing error or "invalid code" */
case 0x99:
......@@ -171,7 +156,7 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
case 0xd8:
*state = REMOTE_NO_KEY_PRESSED;
m->rep_count = 0;
goto out;
break;
case 0x93:
case 0x92:
......@@ -179,7 +164,7 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
case 0x82:
m->rep_count = 0;
*state = REMOTE_KEY_PRESSED;
goto out;
break;
case 0x91:
case 0x81: /* pinnacle PCTV310e */
......@@ -188,13 +173,35 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
*state = REMOTE_KEY_REPEAT;
else
*state = REMOTE_NO_KEY_PRESSED;
goto out;
break;
default:
deb("Unexpected rc state %02x\n", rc_state[0]);
deb("Unexpected rc state %02x\n", rc_state);
*state = REMOTE_NO_KEY_PRESSED;
goto out;
break;
}
}
static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
{
int i, ret = 0;
u8 *rc_state;
rc_state = kmalloc(2, GFP_KERNEL);
if (!rc_state)
return -ENOMEM;
if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
goto out;
if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
goto out;
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
if (rc5_data(&d->props.rc.legacy.rc_map_table[i]) == rc_state[1]) {
*event = d->props.rc.legacy.rc_map_table[i].keycode;
m920x_parse_rc_state(d, rc_state[0], state);
goto out;
}
if (rc_state[1] != 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment