From: AH <andrzej.hajda@wp.pl>
To: linux-media@vger.kernel.org
Subject: [PATCH] cx88: High resolution timer for Remote Controls
Date: Thu, 04 Jun 2009 18:49:32 +0200 [thread overview]
Message-ID: <4A27FB1C.6080704@wp.pl> (raw)
Patch solves problem of missed keystrokes on some remote controls,
as reported on http://bugzilla.kernel.org/show_bug.cgi?id=9637 .
---
Signed-off-by: Andrzej Hajda <andrzej.hajda@wp.pl <mailto:andrzej.hajda@wp.pl>>
Acked-by: Jean Delvare <khali@linux-fr.org <mailto:khali@linux-fr.org>>
---
diff -r 315bc4b65b4f linux/drivers/media/video/cx88/cx88-input.c
--- a/linux/drivers/media/video/cx88/cx88-input.c Sun May 17 12:28:55
2009 +0000
+++ b/linux/drivers/media/video/cx88/cx88-input.c Sat May 30 14:16:24
2009 +0200
@@ -23,10 +23,10 @@
*/
#include <linux/init.h>
-#include <linux/delay.h>
#include <linux/input.h>
#include <linux/pci.h>
#include <linux/module.h>
+#include <linux/hrtimer.h>
#include "compat.h"
#include "cx88.h"
@@ -49,7 +49,7 @@ struct cx88_IR {
/* poll external decoder */
int polling;
- struct delayed_work work;
+ struct hrtimer timer;
u32 gpio_addr;
u32 last_gpio;
u32 mask_keycode;
@@ -144,31 +144,27 @@ static void cx88_ir_handle_key(struct cx
}
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void cx88_ir_work(void *data)
-#else
-static void cx88_ir_work(struct work_struct *work)
-#endif
+enum hrtimer_restart cx88_ir_work(struct hrtimer *timer)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- struct cx88_IR *ir = data;
-#else
- struct cx88_IR *ir = container_of(work, struct cx88_IR, work.work);
-#endif
+ unsigned long missed;
+ struct cx88_IR *ir = container_of(timer, struct cx88_IR, timer);
cx88_ir_handle_key(ir);
- schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling));
+ missed = hrtimer_forward_now(&ir->timer,
+ ktime_set(0, ir->polling * 1000000));
+ if (missed > 1)
+ ir_dprintk("Missed ticks %ld\n", missed - 1);
+
+ return HRTIMER_RESTART;
}
void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir)
{
if (ir->polling) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- INIT_DELAYED_WORK(&ir->work, cx88_ir_work, ir);
-#else
- INIT_DELAYED_WORK(&ir->work, cx88_ir_work);
-#endif
- schedule_delayed_work(&ir->work, 0);
+ hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ ir->timer.function = cx88_ir_work;
+ hrtimer_start(&ir->timer, ktime_set(0, ir->polling * 1000000),
+ HRTIMER_MODE_REL);
}
if (ir->sampling) {
core->pci_irqmask |= PCI_INT_IR_SMPINT;
@@ -185,7 +181,7 @@ void cx88_ir_stop(struct cx88_core *core
}
if (ir->polling)
- cancel_delayed_work_sync(&ir->work);
+ hrtimer_cancel(&ir->timer);
}
/*
---------------------------------------------------------------------- */
next reply other threads:[~2009-06-04 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-04 16:49 AH [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-07-02 14:50 [PATCH] cx88: High resolution timer for Remote Controls Jean Delvare
2009-07-03 20:37 ` Jean Delvare
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=4A27FB1C.6080704@wp.pl \
--to=andrzej.hajda@wp.pl \
--cc=linux-media@vger.kernel.org \
/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