aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-04-02 14:58:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:56:54 -0400
commit13c24497086418010bf4f76378bcae241d7f59cd (patch)
treef49eb154990236c76008b2cccd5702a3539e8c14
parenta374fef4437abd0a1ee27afe0cca7a55425c1c3c (diff)
V4L/DVB: Convert drivers/media/dvb/ttpci/budget-ci.c to use ir-core
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. [mchehab@redhat.com: Drop the call to ir_input_init() as it is no longer needed] Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c40
1 files changed, 3 insertions, 37 deletions
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index be2074995a0d..461714396331 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -35,7 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/input.h> 36#include <linux/input.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <media/ir-common.h> 38#include <media/ir-core.h>
39 39
40#include "budget.h" 40#include "budget.h"
41 41
@@ -82,12 +82,6 @@
82#define SLOTSTATUS_READY 8 82#define SLOTSTATUS_READY 8
83#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY) 83#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
84 84
85/*
86 * Milliseconds during which a key is regarded as pressed.
87 * If an identical command arrives within this time, the timer will start over.
88 */
89#define IR_KEYPRESS_TIMEOUT 250
90
91/* RC5 device wildcard */ 85/* RC5 device wildcard */
92#define IR_DEVICE_ANY 255 86#define IR_DEVICE_ANY 255
93 87
@@ -104,12 +98,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
104struct budget_ci_ir { 98struct budget_ci_ir {
105 struct input_dev *dev; 99 struct input_dev *dev;
106 struct tasklet_struct msp430_irq_tasklet; 100 struct tasklet_struct msp430_irq_tasklet;
107 struct timer_list timer_keyup;
108 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ 101 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
109 char phys[32]; 102 char phys[32];
110 struct ir_input_state state;
111 int rc5_device; 103 int rc5_device;
112 u32 last_raw;
113 u32 ir_key; 104 u32 ir_key;
114 bool have_command; 105 bool have_command;
115}; 106};
@@ -124,18 +115,11 @@ struct budget_ci {
124 u8 tuner_pll_address; /* used for philips_tdm1316l configs */ 115 u8 tuner_pll_address; /* used for philips_tdm1316l configs */
125}; 116};
126 117
127static void msp430_ir_keyup(unsigned long data)
128{
129 struct budget_ci_ir *ir = (struct budget_ci_ir *) data;
130 ir_input_nokey(ir->dev, &ir->state);
131}
132
133static void msp430_ir_interrupt(unsigned long data) 118static void msp430_ir_interrupt(unsigned long data)
134{ 119{
135 struct budget_ci *budget_ci = (struct budget_ci *) data; 120 struct budget_ci *budget_ci = (struct budget_ci *) data;
136 struct input_dev *dev = budget_ci->ir.dev; 121 struct input_dev *dev = budget_ci->ir.dev;
137 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; 122 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
138 u32 raw;
139 123
140 /* 124 /*
141 * The msp430 chip can generate two different bytes, command and device 125 * The msp430 chip can generate two different bytes, command and device
@@ -171,20 +155,12 @@ static void msp430_ir_interrupt(unsigned long data)
171 return; 155 return;
172 budget_ci->ir.have_command = false; 156 budget_ci->ir.have_command = false;
173 157
158 /* FIXME: We should generate complete scancodes with device info */
174 if (budget_ci->ir.rc5_device != IR_DEVICE_ANY && 159 if (budget_ci->ir.rc5_device != IR_DEVICE_ANY &&
175 budget_ci->ir.rc5_device != (command & 0x1f)) 160 budget_ci->ir.rc5_device != (command & 0x1f))
176 return; 161 return;
177 162
178 /* Is this a repeated key sequence? (same device, command, toggle) */ 163 ir_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
179 raw = budget_ci->ir.ir_key | (command << 8);
180 if (budget_ci->ir.last_raw != raw || !timer_pending(&budget_ci->ir.timer_keyup)) {
181 ir_input_nokey(dev, &budget_ci->ir.state);
182 ir_input_keydown(dev, &budget_ci->ir.state,
183 budget_ci->ir.ir_key);
184 budget_ci->ir.last_raw = raw;
185 }
186
187 mod_timer(&budget_ci->ir.timer_keyup, jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT));
188} 164}
189 165
190static int msp430_ir_init(struct budget_ci *budget_ci) 166static int msp430_ir_init(struct budget_ci *budget_ci)
@@ -249,13 +225,6 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
249 break; 225 break;
250 } 226 }
251 227
252 ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5);
253
254 /* initialise the key-up timeout handler */
255 init_timer(&budget_ci->ir.timer_keyup);
256 budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
257 budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
258 budget_ci->ir.last_raw = 0xffff; /* An impossible value */
259 error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME); 228 error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
260 if (error) { 229 if (error) {
261 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error); 230 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
@@ -284,9 +253,6 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
284 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 253 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
285 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); 254 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
286 255
287 del_timer_sync(&dev->timer);
288 ir_input_nokey(dev, &budget_ci->ir.state);
289
290 ir_input_unregister(dev); 256 ir_input_unregister(dev);
291} 257}
292 258