From: "David Härdeman" <david@hardeman.nu>
To: mchehab@redhat.com
Cc: linux-media@vger.kernel.org
Subject: [PATCH 2/8] ir-core: convert em28xx to not use ir-functions.c
Date: Mon, 07 Jun 2010 21:32:23 +0200 [thread overview]
Message-ID: <20100607193223.21236.36477.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100607192830.21236.69701.stgit@localhost.localdomain>
Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c
Signed-off-by: David Härdeman <david@hardeman.nu>
---
drivers/media/video/em28xx/em28xx-input.c | 65 +++++++----------------------
drivers/media/video/em28xx/em28xx.h | 1
2 files changed, 17 insertions(+), 49 deletions(-)
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index dffd026..c4d6027 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -64,17 +64,14 @@ struct em28xx_ir_poll_result {
struct em28xx_IR {
struct em28xx *dev;
struct input_dev *input;
- struct ir_input_state ir;
char name[32];
char phys[32];
/* poll external decoder */
int polling;
struct delayed_work work;
- unsigned int last_toggle:1;
unsigned int full_code:1;
unsigned int last_readcount;
- unsigned int repeat_interval;
int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
@@ -290,7 +287,6 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
static void em28xx_ir_handle_key(struct em28xx_IR *ir)
{
int result;
- int do_sendkey = 0;
struct em28xx_ir_poll_result poll_result;
/* read the registers containing the IR status */
@@ -305,52 +301,28 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
ir->last_readcount, poll_result.rc_address,
poll_result.rc_data[0]);
- if (ir->dev->chip_id == CHIP_ID_EM2874) {
+ if (poll_result.read_count > 0 &&
+ poll_result.read_count != ir->last_readcount) {
+ if (ir->full_code)
+ ir_keydown(ir->input,
+ poll_result.rc_address << 8 |
+ poll_result.rc_data[0],
+ poll_result.toggle_bit);
+ else
+ ir_keydown(ir->input,
+ poll_result.rc_data[0],
+ poll_result.toggle_bit);
+ }
+
+ if (ir->dev->chip_id == CHIP_ID_EM2874)
/* The em2874 clears the readcount field every time the
register is read. The em2860/2880 datasheet says that it
is supposed to clear the readcount, but it doesn't. So with
the em2874, we are looking for a non-zero read count as
opposed to a readcount that is incrementing */
ir->last_readcount = 0;
- }
-
- if (poll_result.read_count == 0) {
- /* The button has not been pressed since the last read */
- } else if (ir->last_toggle != poll_result.toggle_bit) {
- /* A button has been pressed */
- dprintk("button has been pressed\n");
- ir->last_toggle = poll_result.toggle_bit;
- ir->repeat_interval = 0;
- do_sendkey = 1;
- } else if (poll_result.toggle_bit == ir->last_toggle &&
- poll_result.read_count > 0 &&
- poll_result.read_count != ir->last_readcount) {
- /* The button is still being held down */
- dprintk("button being held down\n");
-
- /* Debouncer for first keypress */
- if (ir->repeat_interval++ > 9) {
- /* Start repeating after 1 second */
- do_sendkey = 1;
- }
- }
-
- if (do_sendkey) {
- dprintk("sending keypress\n");
-
- if (ir->full_code)
- ir_input_keydown(ir->input, &ir->ir,
- poll_result.rc_address << 8 |
- poll_result.rc_data[0]);
- else
- ir_input_keydown(ir->input, &ir->ir,
- poll_result.rc_data[0]);
-
- ir_input_nokey(ir->input, &ir->ir);
- }
-
- ir->last_readcount = poll_result.read_count;
- return;
+ else
+ ir->last_readcount = poll_result.read_count;
}
static void em28xx_ir_work(struct work_struct *work)
@@ -465,11 +437,6 @@ int em28xx_ir_init(struct em28xx *dev)
usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
strlcat(ir->phys, "/input0", sizeof(ir->phys));
- /* Set IR protocol */
- err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER);
- if (err < 0)
- goto err_out_free;
-
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_USB;
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index b252d1b..6216786 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -32,6 +32,7 @@
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <media/ir-kbd-i2c.h>
+#include <media/ir-core.h>
#if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE)
#include <media/videobuf-dvb.h>
#endif
next prev parent reply other threads:[~2010-06-07 19:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
2010-06-07 19:32 ` [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c David Härdeman
2010-06-07 19:32 ` David Härdeman [this message]
2010-06-27 10:23 ` [PATCH 2/8] ir-core: convert em28xx " Mauro Carvalho Chehab
2010-06-27 11:19 ` Mauro Carvalho Chehab
2010-06-07 19:32 ` [PATCH 3/8] ir-core: partially convert cx88 " David Härdeman
2010-06-07 19:32 ` [PATCH 4/8] ir-core: partially convert ir-kbd-i2c.c " David Härdeman
2010-06-07 19:32 ` [PATCH 5/8] ir-core: partially convert bt8xx " David Härdeman
2010-06-27 12:11 ` Mauro Carvalho Chehab
2010-06-27 15:14 ` Andy Walls
2010-06-28 1:26 ` Mauro Carvalho Chehab
2010-06-27 20:17 ` Jarod Wilson
2010-06-27 21:37 ` Andy Walls
2010-06-27 23:17 ` MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev? Andy Walls
2010-06-28 3:34 ` Jarod Wilson
2010-07-03 13:20 ` Andy Walls
2010-06-07 19:32 ` [PATCH 6/8] ir-core: centralize sysfs raw decoder enabling/disabling David Härdeman
2010-06-07 19:32 ` [PATCH 7/8] ir-core: move decoding state to ir_raw_event_ctrl David Härdeman
2010-06-07 19:32 ` [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h David Härdeman
2010-06-28 17:45 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100607193223.21236.36477.stgit@localhost.localdomain \
--to=david@hardeman.nu \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox