Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 161586
b: refs/heads/master
c: b77f0a7
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Sep 12, 2009
1 parent bd6e506 commit f1f4829
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2e3658836efad06662968bd6373c72df06c4b2f1
refs/heads/master: b77f0a76304dae754003b0a84fb4f66bf9934c97
56 changes: 56 additions & 0 deletions trunk/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,58 @@
#include "dvb-usb-common.h"
#include <linux/usb/input.h>

static int dvb_usb_getkeycode(struct input_dev *dev,
int scancode, int *keycode)
{
struct dvb_usb_device *d = input_get_drvdata(dev);

struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
int i;

/* See if we can match the raw key code. */
for (i = 0; i < d->props.rc_key_map_size; i++)
if (keymap[i].scan == scancode) {
*keycode = keymap[i].event;
return 0;
}
return -EINVAL;
}

static int dvb_usb_setkeycode(struct input_dev *dev,
int scancode, int keycode)
{
struct dvb_usb_device *d = input_get_drvdata(dev);

struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
int i;

/* Search if it is replacing an existing keycode */
for (i = 0; i < d->props.rc_key_map_size; i++)
if (keymap[i].scan == scancode) {
keymap[i].event = keycode;
return 0;
}

/* Search if is there a clean entry. If so, use it */
for (i = 0; i < d->props.rc_key_map_size; i++)
if (keymap[i].event == KEY_RESERVED ||
keymap[i].event == KEY_UNKNOWN) {
keymap[i].scan = scancode;
keymap[i].event = keycode;
return 0;
}

/*
* FIXME: Currently, it is not possible to increase the size of
* scancode table. For it to happen, one possibility
* would be to allocate a table with key_map_size + 1,
* copying data, appending the new key on it, and freeing
* the old one - or maybe just allocating some spare space
*/

return -EINVAL;
}

/* Remote-control poll function - called every dib->rc_query_interval ms to see
* whether the remote control has received anything.
*
Expand Down Expand Up @@ -111,6 +163,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
input_dev->phys = d->rc_phys;
usb_to_input_id(d->udev, &input_dev->id);
input_dev->dev.parent = &d->udev->dev;
input_dev->getkeycode = dvb_usb_getkeycode;
input_dev->setkeycode = dvb_usb_setkeycode;

/* set the bits for the keys */
deb_rc("key map size: %d\n", d->props.rc_key_map_size);
Expand All @@ -128,6 +182,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
input_dev->rep[REP_PERIOD] = d->props.rc_interval;
input_dev->rep[REP_DELAY] = d->props.rc_interval + 150;

input_set_drvdata(input_dev, d);

err = input_register_device(input_dev);
if (err) {
input_free_device(input_dev);
Expand Down

0 comments on commit f1f4829

Please sign in to comment.