public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com> (by way of Mauro Carvalho Chehab <mchehab@redhat.com>)
To: linux-media@vger.kernel.org,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH 17/26] V4L/DVB: Convert drivers/media/dvb/ttpci/budget-ci.c to use ir-core
Date: Tue, 6 Apr 2010 15:18:02 -0300	[thread overview]
Message-ID: <20100406151802.7f564b3d@pedra> (raw)
In-Reply-To: <cover.1270577768.git.mchehab@redhat.com>

From: David Härdeman <david@hardeman.nu>

Converts drivers/media/dvb/ttpci/budget-ci.c to use ir-core rather than
rolling its own keydown timeout handler and reporting keys via
drivers/media/IR/ir-functions.c.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index be20749..8950df1 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -35,7 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/spinlock.h>
-#include <media/ir-common.h>
+#include <media/ir-core.h>
 
 #include "budget.h"
 
@@ -82,12 +82,6 @@
 #define SLOTSTATUS_READY	8
 #define SLOTSTATUS_OCCUPIED	(SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
 
-/*
- * Milliseconds during which a key is regarded as pressed.
- * If an identical command arrives within this time, the timer will start over.
- */
-#define IR_KEYPRESS_TIMEOUT	250
-
 /* RC5 device wildcard */
 #define IR_DEVICE_ANY		255
 
@@ -104,12 +98,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 struct budget_ci_ir {
 	struct input_dev *dev;
 	struct tasklet_struct msp430_irq_tasklet;
-	struct timer_list timer_keyup;
 	char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
 	char phys[32];
-	struct ir_input_state state;
 	int rc5_device;
-	u32 last_raw;
 	u32 ir_key;
 	bool have_command;
 };
@@ -124,18 +115,11 @@ struct budget_ci {
 	u8 tuner_pll_address; /* used for philips_tdm1316l configs */
 };
 
-static void msp430_ir_keyup(unsigned long data)
-{
-	struct budget_ci_ir *ir = (struct budget_ci_ir *) data;
-	ir_input_nokey(ir->dev, &ir->state);
-}
-
 static void msp430_ir_interrupt(unsigned long data)
 {
 	struct budget_ci *budget_ci = (struct budget_ci *) data;
 	struct input_dev *dev = budget_ci->ir.dev;
 	u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
-	u32 raw;
 
 	/*
 	 * The msp430 chip can generate two different bytes, command and device
@@ -171,20 +155,12 @@ static void msp430_ir_interrupt(unsigned long data)
 		return;
 	budget_ci->ir.have_command = false;
 
+	/* FIXME: We should generate complete scancodes with device info */
 	if (budget_ci->ir.rc5_device != IR_DEVICE_ANY &&
 	    budget_ci->ir.rc5_device != (command & 0x1f))
 		return;
 
-	/* Is this a repeated key sequence? (same device, command, toggle) */
-	raw = budget_ci->ir.ir_key | (command << 8);
-	if (budget_ci->ir.last_raw != raw || !timer_pending(&budget_ci->ir.timer_keyup)) {
-		ir_input_nokey(dev, &budget_ci->ir.state);
-		ir_input_keydown(dev, &budget_ci->ir.state,
-				 budget_ci->ir.ir_key);
-		budget_ci->ir.last_raw = raw;
-	}
-
-	mod_timer(&budget_ci->ir.timer_keyup, jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT));
+	ir_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
 }
 
 static int msp430_ir_init(struct budget_ci *budget_ci)
@@ -251,11 +227,6 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
 
 	ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5);
 
-	/* initialise the key-up timeout handler */
-	init_timer(&budget_ci->ir.timer_keyup);
-	budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
-	budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
-	budget_ci->ir.last_raw = 0xffff; /* An impossible value */
 	error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
 	if (error) {
 		printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
@@ -284,9 +255,6 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
 	saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
 	tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
 
-	del_timer_sync(&dev->timer);
-	ir_input_nokey(dev, &budget_ci->ir.state);
-
 	ir_input_unregister(dev);
 }
 
-- 
1.6.6.1



  parent reply	other threads:[~2010-04-06 19:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1270577768.git.mchehab@redhat.com>
2010-04-06 18:18 ` [PATCH 24/26] V4L/DVB: ir-core: Add support for badly-implemented hardware decoders Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 22/26] V4L-DVB: ir-core: remove the ancillary buffer Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 25/26] V4L/DVB: re-add enable/disable check to the IR decoders Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 26/26] V4L/DVB: ir-rc5-decoder: fix state machine Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 23/26] V4L/DVB: ir-core: move rc map code to rc-map.h Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 18/26] V4L/DVB: ir-nec-decoder: Reimplement the entire decoder Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 20/26] V4L-DVB: ir-rc5-decoder: Add a decoder for RC-5 IR protocol Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 19/26] ir-nec-decoder: Cleanups Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 13/26] V4L/DVB: saa7134: Add support for both positive and negative edge IRQ Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 21/26] V4L/DVB: cx88: don't handle IR on Pixelview too fast Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 15/26] V4L/DVB: ir-core: re-add some debug functions for keytable changes Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 14/26] V4L/DVB: drivers/media/IR - improve keytable code Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 10/26] V4L/DVB: ir-core: Make use of the new IR keymap modules Mauro Carvalho Chehab
2010-04-06 18:18 ` Mauro Carvalho Chehab [this message]
2010-04-06 18:18 ` [PATCH 12/26] V4L/DVB: saa7134: Fix IRQ2 bit names for the register map Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 11/26] V4L/DVB: ir-common: remove keymap tables from the module Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 04/26] V4L/DVB: rename all *_rc_keys to ir_codes_*_nec_table Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 09/26] V4L/DVB: ir: prepare IR code for a parameter change at register function Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 05/26] V4L/DVB: ir-common: Use macros to define the keytables Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 07/26] V4L/DVB: ir-core: Add support for RC map code register Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 08/26] V4L/DVB: Break Remote Controller keymaps into modules Mauro Carvalho Chehab
2010-04-10 12:27   ` Andy Walls
2010-04-10 16:06     ` Mauro Carvalho Chehab
2010-04-10 17:26       ` Andy Walls
2010-04-06 18:18 ` [PATCH 06/26] V4L/DVB: ir-common: move IR tables from ir-keymaps.c to a separate file Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 03/26] V4L/DVB: IR: use IR_KEYTABLE where an IR table is needed Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 01/26] V4L/DVB: ir-common: Use a function to declare an IR table Mauro Carvalho Chehab
2010-04-06 18:18 ` [PATCH 02/26] V4L/DVB: ir-common: re-order keytables by name and remove duplicates Mauro Carvalho Chehab
2010-04-06 19:13 ` [PATCH 16/26] V4L/DVB: ir-core: improve keyup/keydown logic 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=20100406151802.7f564b3d@pedra \
    --to=mchehab@redhat.com \
    --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