aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-04-04 09:44:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:56:57 -0400
commit587835a4b0ada7d78c4f3300e3ab26b7b2495705 (patch)
treead22f6a0e603f19450227b0cb260b5bb5960dfd5 /drivers
parent26d5683d36729f11f5764909ae37c69488596d36 (diff)
V4L-DVB: ir-core: remove the ancillary buffer
Now that the decoders are state machine, there's no need to create an ancillary buffer while decoding the protocol. Just call the decoders code directly, event by event. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/IR/ir-nec-decoder.c32
-rw-r--r--drivers/media/IR/ir-raw-event.c20
-rw-r--r--drivers/media/IR/ir-rc5-decoder.c28
3 files changed, 12 insertions, 68 deletions
diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c
index 087211c5496a..28d773563556 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -125,14 +125,14 @@ static struct attribute_group decoder_attribute_group = {
125 125
126 126
127/** 127/**
128 * handle_event() - Decode one NEC pulse or space 128 * ir_nec_decode() - Decode one NEC pulse or space
129 * @input_dev: the struct input_dev descriptor of the device 129 * @input_dev: the struct input_dev descriptor of the device
130 * @ev: event array with type/duration of pulse/space 130 * @ev: event array with type/duration of pulse/space
131 * 131 *
132 * This function returns -EINVAL if the pulse violates the state machine 132 * This function returns -EINVAL if the pulse violates the state machine
133 */ 133 */
134static int handle_event(struct input_dev *input_dev, 134static int ir_nec_decode(struct input_dev *input_dev,
135 struct ir_raw_event *ev) 135 struct ir_raw_event *ev)
136{ 136{
137 struct decoder_data *data; 137 struct decoder_data *data;
138 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 138 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
@@ -289,32 +289,6 @@ checksum_err:
289 return -EINVAL; 289 return -EINVAL;
290} 290}
291 291
292/**
293 * ir_nec_decode() - Decodes all NEC pulsecodes on a given array
294 * @input_dev: the struct input_dev descriptor of the device
295 * @evs: event array with type/duration of pulse/space
296 * @len: length of the array
297 * This function returns the number of decoded pulses
298 */
299static int ir_nec_decode(struct input_dev *input_dev,
300 struct ir_raw_event *evs,
301 int len)
302{
303 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
304 struct decoder_data *data;
305 int pos = 0;
306 int rc = 0;
307
308 data = get_decoder_data(ir_dev);
309 if (!data || !data->enabled)
310 return 0;
311
312 for (pos = 0; pos < len; pos++)
313 handle_event(input_dev, &evs[pos]);
314
315 return rc;
316}
317
318static int ir_nec_register(struct input_dev *input_dev) 292static int ir_nec_register(struct input_dev *input_dev)
319{ 293{
320 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 294 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 617e437e2beb..57990a337922 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -138,37 +138,33 @@ int ir_raw_event_handle(struct input_dev *input_dev)
138{ 138{
139 struct ir_input_dev *ir = input_get_drvdata(input_dev); 139 struct ir_input_dev *ir = input_get_drvdata(input_dev);
140 int rc; 140 int rc;
141 struct ir_raw_event *evs; 141 struct ir_raw_event ev;
142 int len, i; 142 int len, i;
143 143
144 /* 144 /*
145 * Store the events into a temporary buffer. This allows calling more than 145 * Store the events into a temporary buffer. This allows calling more than
146 * one decoder to deal with the received data 146 * one decoder to deal with the received data
147 */ 147 */
148 len = kfifo_len(&ir->raw->kfifo) / sizeof(*evs); 148 len = kfifo_len(&ir->raw->kfifo) / sizeof(ev);
149 if (!len) 149 if (!len)
150 return 0; 150 return 0;
151 evs = kmalloc(len * sizeof(*evs), GFP_ATOMIC);
152 151
153 for (i = 0; i < len; i++) { 152 for (i = 0; i < len; i++) {
154 rc = kfifo_out(&ir->raw->kfifo, &evs[i], sizeof(*evs)); 153 rc = kfifo_out(&ir->raw->kfifo, &ev, sizeof(ev));
155 if (rc != sizeof(*evs)) { 154 if (rc != sizeof(ev)) {
156 IR_dprintk(1, "overflow error: received %d instead of %zd\n", 155 IR_dprintk(1, "overflow error: received %d instead of %zd\n",
157 rc, sizeof(*evs)); 156 rc, sizeof(ev));
158 return -EINVAL; 157 return -EINVAL;
159 } 158 }
160 IR_dprintk(2, "event type %d, time before event: %07luus\n", 159 IR_dprintk(2, "event type %d, time before event: %07luus\n",
161 evs[i].type, (evs[i].delta.tv_nsec + 500) / 1000); 160 ev.type, (ev.delta.tv_nsec + 500) / 1000);
161 rc = RUN_DECODER(decode, input_dev, &ev);
162 } 162 }
163 163
164 /* 164 /*
165 * Call all ir decoders. This allows decoding the same event with 165 * Call all ir decoders. This allows decoding the same event with
166 * more than one protocol handler. It returns the number of keystrokes 166 * more than one protocol handler.
167 * sent to the event interface
168 */ 167 */
169 rc = RUN_DECODER(decode, input_dev, evs, len);
170
171 kfree(evs);
172 168
173 return rc; 169 return rc;
174} 170}
diff --git a/drivers/media/IR/ir-rc5-decoder.c b/drivers/media/IR/ir-rc5-decoder.c
index 4b7eafecd842..61b58397a3c2 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -142,7 +142,7 @@ static struct attribute_group decoder_attribute_group = {
142 * 142 *
143 * This function returns -EINVAL if the pulse violates the state machine 143 * This function returns -EINVAL if the pulse violates the state machine
144 */ 144 */
145static int handle_event(struct input_dev *input_dev, 145static int ir_rc5_decode(struct input_dev *input_dev,
146 struct ir_raw_event *ev) 146 struct ir_raw_event *ev)
147{ 147{
148 struct decoder_data *data; 148 struct decoder_data *data;
@@ -273,32 +273,6 @@ err2:
273 return -EINVAL; 273 return -EINVAL;
274} 274}
275 275
276/**
277 * ir_rc5_decode() - Decodes all RC-5 pulsecodes on a given array
278 * @input_dev: the struct input_dev descriptor of the device
279 * @evs: event array with type/duration of pulse/space
280 * @len: length of the array
281 * This function returns the number of decoded pulses
282 */
283static int ir_rc5_decode(struct input_dev *input_dev,
284 struct ir_raw_event *evs,
285 int len)
286{
287 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
288 struct decoder_data *data;
289 int pos = 0;
290 int rc = 0;
291
292 data = get_decoder_data(ir_dev);
293 if (!data || !data->enabled)
294 return 0;
295
296 for (pos = 0; pos < len; pos++)
297 handle_event(input_dev, &evs[pos]);
298
299 return rc;
300}
301
302static int ir_rc5_register(struct input_dev *input_dev) 276static int ir_rc5_register(struct input_dev *input_dev)
303{ 277{
304 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 278 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);