diff options
Diffstat (limited to 'drivers/media/IR/streamzap.c')
-rw-r--r-- | drivers/media/IR/streamzap.c | 376 |
1 files changed, 102 insertions, 274 deletions
diff --git a/drivers/media/IR/streamzap.c b/drivers/media/IR/streamzap.c index 058e29fd478c..548381c35bfd 100644 --- a/drivers/media/IR/streamzap.c +++ b/drivers/media/IR/streamzap.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/input.h> | 38 | #include <linux/input.h> |
39 | #include <media/ir-core.h> | 39 | #include <media/ir-core.h> |
40 | 40 | ||
41 | #define DRIVER_VERSION "1.60" | 41 | #define DRIVER_VERSION "1.61" |
42 | #define DRIVER_NAME "streamzap" | 42 | #define DRIVER_NAME "streamzap" |
43 | #define DRIVER_DESC "Streamzap Remote Control driver" | 43 | #define DRIVER_DESC "Streamzap Remote Control driver" |
44 | 44 | ||
@@ -61,14 +61,21 @@ static struct usb_device_id streamzap_table[] = { | |||
61 | 61 | ||
62 | MODULE_DEVICE_TABLE(usb, streamzap_table); | 62 | MODULE_DEVICE_TABLE(usb, streamzap_table); |
63 | 63 | ||
64 | #define STREAMZAP_PULSE_MASK 0xf0 | 64 | #define SZ_PULSE_MASK 0xf0 |
65 | #define STREAMZAP_SPACE_MASK 0x0f | 65 | #define SZ_SPACE_MASK 0x0f |
66 | #define STREAMZAP_TIMEOUT 0xff | 66 | #define SZ_TIMEOUT 0xff |
67 | #define STREAMZAP_RESOLUTION 256 | 67 | #define SZ_RESOLUTION 256 |
68 | 68 | ||
69 | /* number of samples buffered */ | 69 | /* number of samples buffered */ |
70 | #define SZ_BUF_LEN 128 | 70 | #define SZ_BUF_LEN 128 |
71 | 71 | ||
72 | /* from ir-rc5-sz-decoder.c */ | ||
73 | #ifdef CONFIG_IR_RC5_SZ_DECODER_MODULE | ||
74 | #define load_rc5_sz_decode() request_module("ir-rc5-sz-decoder") | ||
75 | #else | ||
76 | #define load_rc5_sz_decode() 0 | ||
77 | #endif | ||
78 | |||
72 | enum StreamzapDecoderState { | 79 | enum StreamzapDecoderState { |
73 | PulseSpace, | 80 | PulseSpace, |
74 | FullPulse, | 81 | FullPulse, |
@@ -81,7 +88,6 @@ struct streamzap_ir { | |||
81 | 88 | ||
82 | /* ir-core */ | 89 | /* ir-core */ |
83 | struct ir_dev_props *props; | 90 | struct ir_dev_props *props; |
84 | struct ir_raw_event rawir; | ||
85 | 91 | ||
86 | /* core device info */ | 92 | /* core device info */ |
87 | struct device *dev; | 93 | struct device *dev; |
@@ -98,17 +104,6 @@ struct streamzap_ir { | |||
98 | dma_addr_t dma_in; | 104 | dma_addr_t dma_in; |
99 | unsigned int buf_in_len; | 105 | unsigned int buf_in_len; |
100 | 106 | ||
101 | /* timer used to support delay buffering */ | ||
102 | struct timer_list delay_timer; | ||
103 | bool timer_running; | ||
104 | spinlock_t timer_lock; | ||
105 | struct timer_list flush_timer; | ||
106 | bool flush; | ||
107 | |||
108 | /* delay buffer */ | ||
109 | struct kfifo fifo; | ||
110 | bool fifo_initialized; | ||
111 | |||
112 | /* track what state we're in */ | 107 | /* track what state we're in */ |
113 | enum StreamzapDecoderState decoder_state; | 108 | enum StreamzapDecoderState decoder_state; |
114 | /* tracks whether we are currently receiving some signal */ | 109 | /* tracks whether we are currently receiving some signal */ |
@@ -118,7 +113,7 @@ struct streamzap_ir { | |||
118 | /* start time of signal; necessary for gap tracking */ | 113 | /* start time of signal; necessary for gap tracking */ |
119 | struct timeval signal_last; | 114 | struct timeval signal_last; |
120 | struct timeval signal_start; | 115 | struct timeval signal_start; |
121 | /* bool timeout_enabled; */ | 116 | bool timeout_enabled; |
122 | 117 | ||
123 | char name[128]; | 118 | char name[128]; |
124 | char phys[64]; | 119 | char phys[64]; |
@@ -143,122 +138,16 @@ static struct usb_driver streamzap_driver = { | |||
143 | .id_table = streamzap_table, | 138 | .id_table = streamzap_table, |
144 | }; | 139 | }; |
145 | 140 | ||
146 | static void streamzap_stop_timer(struct streamzap_ir *sz) | 141 | static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir) |
147 | { | ||
148 | unsigned long flags; | ||
149 | |||
150 | spin_lock_irqsave(&sz->timer_lock, flags); | ||
151 | if (sz->timer_running) { | ||
152 | sz->timer_running = false; | ||
153 | spin_unlock_irqrestore(&sz->timer_lock, flags); | ||
154 | del_timer_sync(&sz->delay_timer); | ||
155 | } else { | ||
156 | spin_unlock_irqrestore(&sz->timer_lock, flags); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | static void streamzap_flush_timeout(unsigned long arg) | ||
161 | { | ||
162 | struct streamzap_ir *sz = (struct streamzap_ir *)arg; | ||
163 | |||
164 | dev_info(sz->dev, "%s: callback firing\n", __func__); | ||
165 | |||
166 | /* finally start accepting data */ | ||
167 | sz->flush = false; | ||
168 | } | ||
169 | |||
170 | static void streamzap_delay_timeout(unsigned long arg) | ||
171 | { | ||
172 | struct streamzap_ir *sz = (struct streamzap_ir *)arg; | ||
173 | struct ir_raw_event rawir = { .pulse = false, .duration = 0 }; | ||
174 | unsigned long flags; | ||
175 | int len, ret; | ||
176 | static unsigned long delay; | ||
177 | bool wake = false; | ||
178 | |||
179 | /* deliver data every 10 ms */ | ||
180 | delay = msecs_to_jiffies(10); | ||
181 | |||
182 | spin_lock_irqsave(&sz->timer_lock, flags); | ||
183 | |||
184 | if (kfifo_len(&sz->fifo) > 0) { | ||
185 | ret = kfifo_out(&sz->fifo, &rawir, sizeof(rawir)); | ||
186 | if (ret != sizeof(rawir)) | ||
187 | dev_err(sz->dev, "Problem w/kfifo_out...\n"); | ||
188 | ir_raw_event_store(sz->idev, &rawir); | ||
189 | wake = true; | ||
190 | } | ||
191 | |||
192 | len = kfifo_len(&sz->fifo); | ||
193 | if (len > 0) { | ||
194 | while ((len < SZ_BUF_LEN / 2) && | ||
195 | (len < SZ_BUF_LEN * sizeof(int))) { | ||
196 | ret = kfifo_out(&sz->fifo, &rawir, sizeof(rawir)); | ||
197 | if (ret != sizeof(rawir)) | ||
198 | dev_err(sz->dev, "Problem w/kfifo_out...\n"); | ||
199 | ir_raw_event_store(sz->idev, &rawir); | ||
200 | wake = true; | ||
201 | len = kfifo_len(&sz->fifo); | ||
202 | } | ||
203 | if (sz->timer_running) | ||
204 | mod_timer(&sz->delay_timer, jiffies + delay); | ||
205 | |||
206 | } else { | ||
207 | sz->timer_running = false; | ||
208 | } | ||
209 | |||
210 | if (wake) | ||
211 | ir_raw_event_handle(sz->idev); | ||
212 | |||
213 | spin_unlock_irqrestore(&sz->timer_lock, flags); | ||
214 | } | ||
215 | |||
216 | static void streamzap_flush_delay_buffer(struct streamzap_ir *sz) | ||
217 | { | 142 | { |
218 | struct ir_raw_event rawir = { .pulse = false, .duration = 0 }; | 143 | ir_raw_event_store(sz->idev, &rawir); |
219 | bool wake = false; | ||
220 | int ret; | ||
221 | |||
222 | while (kfifo_len(&sz->fifo) > 0) { | ||
223 | ret = kfifo_out(&sz->fifo, &rawir, sizeof(rawir)); | ||
224 | if (ret != sizeof(rawir)) | ||
225 | dev_err(sz->dev, "Problem w/kfifo_out...\n"); | ||
226 | ir_raw_event_store(sz->idev, &rawir); | ||
227 | wake = true; | ||
228 | } | ||
229 | |||
230 | if (wake) | ||
231 | ir_raw_event_handle(sz->idev); | ||
232 | } | ||
233 | |||
234 | static void sz_push(struct streamzap_ir *sz) | ||
235 | { | ||
236 | struct ir_raw_event rawir = { .pulse = false, .duration = 0 }; | ||
237 | unsigned long flags; | ||
238 | int ret; | ||
239 | |||
240 | spin_lock_irqsave(&sz->timer_lock, flags); | ||
241 | if (kfifo_len(&sz->fifo) >= sizeof(int) * SZ_BUF_LEN) { | ||
242 | ret = kfifo_out(&sz->fifo, &rawir, sizeof(rawir)); | ||
243 | if (ret != sizeof(rawir)) | ||
244 | dev_err(sz->dev, "Problem w/kfifo_out...\n"); | ||
245 | ir_raw_event_store(sz->idev, &rawir); | ||
246 | } | ||
247 | |||
248 | kfifo_in(&sz->fifo, &sz->rawir, sizeof(rawir)); | ||
249 | |||
250 | if (!sz->timer_running) { | ||
251 | sz->delay_timer.expires = jiffies + (HZ / 10); | ||
252 | add_timer(&sz->delay_timer); | ||
253 | sz->timer_running = true; | ||
254 | } | ||
255 | |||
256 | spin_unlock_irqrestore(&sz->timer_lock, flags); | ||
257 | } | 144 | } |
258 | 145 | ||
259 | static void sz_push_full_pulse(struct streamzap_ir *sz, | 146 | static void sz_push_full_pulse(struct streamzap_ir *sz, |
260 | unsigned char value) | 147 | unsigned char value) |
261 | { | 148 | { |
149 | DEFINE_IR_RAW_EVENT(rawir); | ||
150 | |||
262 | if (sz->idle) { | 151 | if (sz->idle) { |
263 | long deltv; | 152 | long deltv; |
264 | 153 | ||
@@ -266,57 +155,59 @@ static void sz_push_full_pulse(struct streamzap_ir *sz, | |||
266 | do_gettimeofday(&sz->signal_start); | 155 | do_gettimeofday(&sz->signal_start); |
267 | 156 | ||
268 | deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; | 157 | deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; |
269 | sz->rawir.pulse = false; | 158 | rawir.pulse = false; |
270 | if (deltv > 15) { | 159 | if (deltv > 15) { |
271 | /* really long time */ | 160 | /* really long time */ |
272 | sz->rawir.duration = IR_MAX_DURATION; | 161 | rawir.duration = IR_MAX_DURATION; |
273 | } else { | 162 | } else { |
274 | sz->rawir.duration = (int)(deltv * 1000000 + | 163 | rawir.duration = (int)(deltv * 1000000 + |
275 | sz->signal_start.tv_usec - | 164 | sz->signal_start.tv_usec - |
276 | sz->signal_last.tv_usec); | 165 | sz->signal_last.tv_usec); |
277 | sz->rawir.duration -= sz->sum; | 166 | rawir.duration -= sz->sum; |
278 | sz->rawir.duration *= 1000; | 167 | rawir.duration *= 1000; |
279 | sz->rawir.duration &= IR_MAX_DURATION; | 168 | rawir.duration &= IR_MAX_DURATION; |
280 | } | 169 | } |
281 | dev_dbg(sz->dev, "ls %u\n", sz->rawir.duration); | 170 | dev_dbg(sz->dev, "ls %u\n", rawir.duration); |
282 | sz_push(sz); | 171 | sz_push(sz, rawir); |
283 | 172 | ||
284 | sz->idle = 0; | 173 | sz->idle = false; |
285 | sz->sum = 0; | 174 | sz->sum = 0; |
286 | } | 175 | } |
287 | 176 | ||
288 | sz->rawir.pulse = true; | 177 | rawir.pulse = true; |
289 | sz->rawir.duration = ((int) value) * STREAMZAP_RESOLUTION; | 178 | rawir.duration = ((int) value) * SZ_RESOLUTION; |
290 | sz->rawir.duration += STREAMZAP_RESOLUTION / 2; | 179 | rawir.duration += SZ_RESOLUTION / 2; |
291 | sz->sum += sz->rawir.duration; | 180 | sz->sum += rawir.duration; |
292 | sz->rawir.duration *= 1000; | 181 | rawir.duration *= 1000; |
293 | sz->rawir.duration &= IR_MAX_DURATION; | 182 | rawir.duration &= IR_MAX_DURATION; |
294 | dev_dbg(sz->dev, "p %u\n", sz->rawir.duration); | 183 | dev_dbg(sz->dev, "p %u\n", rawir.duration); |
295 | sz_push(sz); | 184 | sz_push(sz, rawir); |
296 | } | 185 | } |
297 | 186 | ||
298 | static void sz_push_half_pulse(struct streamzap_ir *sz, | 187 | static void sz_push_half_pulse(struct streamzap_ir *sz, |
299 | unsigned char value) | 188 | unsigned char value) |
300 | { | 189 | { |
301 | sz_push_full_pulse(sz, (value & STREAMZAP_PULSE_MASK) >> 4); | 190 | sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); |
302 | } | 191 | } |
303 | 192 | ||
304 | static void sz_push_full_space(struct streamzap_ir *sz, | 193 | static void sz_push_full_space(struct streamzap_ir *sz, |
305 | unsigned char value) | 194 | unsigned char value) |
306 | { | 195 | { |
307 | sz->rawir.pulse = false; | 196 | DEFINE_IR_RAW_EVENT(rawir); |
308 | sz->rawir.duration = ((int) value) * STREAMZAP_RESOLUTION; | 197 | |
309 | sz->rawir.duration += STREAMZAP_RESOLUTION / 2; | 198 | rawir.pulse = false; |
310 | sz->sum += sz->rawir.duration; | 199 | rawir.duration = ((int) value) * SZ_RESOLUTION; |
311 | sz->rawir.duration *= 1000; | 200 | rawir.duration += SZ_RESOLUTION / 2; |
312 | dev_dbg(sz->dev, "s %u\n", sz->rawir.duration); | 201 | sz->sum += rawir.duration; |
313 | sz_push(sz); | 202 | rawir.duration *= 1000; |
203 | dev_dbg(sz->dev, "s %u\n", rawir.duration); | ||
204 | sz_push(sz, rawir); | ||
314 | } | 205 | } |
315 | 206 | ||
316 | static void sz_push_half_space(struct streamzap_ir *sz, | 207 | static void sz_push_half_space(struct streamzap_ir *sz, |
317 | unsigned long value) | 208 | unsigned long value) |
318 | { | 209 | { |
319 | sz_push_full_space(sz, value & STREAMZAP_SPACE_MASK); | 210 | sz_push_full_space(sz, value & SZ_SPACE_MASK); |
320 | } | 211 | } |
321 | 212 | ||
322 | /** | 213 | /** |
@@ -330,10 +221,8 @@ static void streamzap_callback(struct urb *urb) | |||
330 | struct streamzap_ir *sz; | 221 | struct streamzap_ir *sz; |
331 | unsigned int i; | 222 | unsigned int i; |
332 | int len; | 223 | int len; |
333 | #if 0 | 224 | static int timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) & |
334 | static int timeout = (((STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION) & | ||
335 | IR_MAX_DURATION) | 0x03000000); | 225 | IR_MAX_DURATION) | 0x03000000); |
336 | #endif | ||
337 | 226 | ||
338 | if (!urb) | 227 | if (!urb) |
339 | return; | 228 | return; |
@@ -356,57 +245,53 @@ static void streamzap_callback(struct urb *urb) | |||
356 | } | 245 | } |
357 | 246 | ||
358 | dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); | 247 | dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); |
359 | if (!sz->flush) { | 248 | for (i = 0; i < len; i++) { |
360 | for (i = 0; i < urb->actual_length; i++) { | 249 | dev_dbg(sz->dev, "sz idx %d: %x\n", |
361 | dev_dbg(sz->dev, "%d: %x\n", i, | 250 | i, (unsigned char)sz->buf_in[i]); |
362 | (unsigned char)sz->buf_in[i]); | 251 | switch (sz->decoder_state) { |
363 | switch (sz->decoder_state) { | 252 | case PulseSpace: |
364 | case PulseSpace: | 253 | if ((sz->buf_in[i] & SZ_PULSE_MASK) == |
365 | if ((sz->buf_in[i] & STREAMZAP_PULSE_MASK) == | 254 | SZ_PULSE_MASK) { |
366 | STREAMZAP_PULSE_MASK) { | 255 | sz->decoder_state = FullPulse; |
367 | sz->decoder_state = FullPulse; | 256 | continue; |
368 | continue; | 257 | } else if ((sz->buf_in[i] & SZ_SPACE_MASK) |
369 | } else if ((sz->buf_in[i] & STREAMZAP_SPACE_MASK) | 258 | == SZ_SPACE_MASK) { |
370 | == STREAMZAP_SPACE_MASK) { | 259 | sz_push_half_pulse(sz, sz->buf_in[i]); |
371 | sz_push_half_pulse(sz, sz->buf_in[i]); | 260 | sz->decoder_state = FullSpace; |
372 | sz->decoder_state = FullSpace; | 261 | continue; |
373 | continue; | 262 | } else { |
374 | } else { | 263 | sz_push_half_pulse(sz, sz->buf_in[i]); |
375 | sz_push_half_pulse(sz, sz->buf_in[i]); | ||
376 | sz_push_half_space(sz, sz->buf_in[i]); | ||
377 | } | ||
378 | break; | ||
379 | case FullPulse: | ||
380 | sz_push_full_pulse(sz, sz->buf_in[i]); | ||
381 | sz->decoder_state = IgnorePulse; | ||
382 | break; | ||
383 | case FullSpace: | ||
384 | if (sz->buf_in[i] == STREAMZAP_TIMEOUT) { | ||
385 | sz->idle = 1; | ||
386 | streamzap_stop_timer(sz); | ||
387 | #if 0 | ||
388 | if (sz->timeout_enabled) { | ||
389 | sz->rawir.pulse = false; | ||
390 | sz->rawir.duration = timeout; | ||
391 | sz->rawir.duration *= 1000; | ||
392 | sz_push(sz); | ||
393 | } | ||
394 | #endif | ||
395 | streamzap_flush_delay_buffer(sz); | ||
396 | } else | ||
397 | sz_push_full_space(sz, sz->buf_in[i]); | ||
398 | sz->decoder_state = PulseSpace; | ||
399 | break; | ||
400 | case IgnorePulse: | ||
401 | if ((sz->buf_in[i]&STREAMZAP_SPACE_MASK) == | ||
402 | STREAMZAP_SPACE_MASK) { | ||
403 | sz->decoder_state = FullSpace; | ||
404 | continue; | ||
405 | } | ||
406 | sz_push_half_space(sz, sz->buf_in[i]); | 264 | sz_push_half_space(sz, sz->buf_in[i]); |
407 | sz->decoder_state = PulseSpace; | ||
408 | break; | ||
409 | } | 265 | } |
266 | break; | ||
267 | case FullPulse: | ||
268 | sz_push_full_pulse(sz, sz->buf_in[i]); | ||
269 | sz->decoder_state = IgnorePulse; | ||
270 | break; | ||
271 | case FullSpace: | ||
272 | if (sz->buf_in[i] == SZ_TIMEOUT) { | ||
273 | DEFINE_IR_RAW_EVENT(rawir); | ||
274 | |||
275 | rawir.pulse = false; | ||
276 | rawir.duration = timeout; | ||
277 | sz->idle = true; | ||
278 | if (sz->timeout_enabled) | ||
279 | sz_push(sz, rawir); | ||
280 | ir_raw_event_handle(sz->idev); | ||
281 | } else { | ||
282 | sz_push_full_space(sz, sz->buf_in[i]); | ||
283 | } | ||
284 | sz->decoder_state = PulseSpace; | ||
285 | break; | ||
286 | case IgnorePulse: | ||
287 | if ((sz->buf_in[i] & SZ_SPACE_MASK) == | ||
288 | SZ_SPACE_MASK) { | ||
289 | sz->decoder_state = FullSpace; | ||
290 | continue; | ||
291 | } | ||
292 | sz_push_half_space(sz, sz->buf_in[i]); | ||
293 | sz->decoder_state = PulseSpace; | ||
294 | break; | ||
410 | } | 295 | } |
411 | } | 296 | } |
412 | 297 | ||
@@ -446,12 +331,11 @@ static struct input_dev *streamzap_init_input_dev(struct streamzap_ir *sz) | |||
446 | 331 | ||
447 | props->priv = sz; | 332 | props->priv = sz; |
448 | props->driver_type = RC_DRIVER_IR_RAW; | 333 | props->driver_type = RC_DRIVER_IR_RAW; |
449 | /* FIXME: not sure about supported protocols, check on this */ | 334 | props->allowed_protos = IR_TYPE_ALL; |
450 | props->allowed_protos = IR_TYPE_RC5 | IR_TYPE_RC6; | ||
451 | 335 | ||
452 | sz->props = props; | 336 | sz->props = props; |
453 | 337 | ||
454 | ret = ir_input_register(idev, RC_MAP_RC5_STREAMZAP, props, DRIVER_NAME); | 338 | ret = ir_input_register(idev, RC_MAP_STREAMZAP, props, DRIVER_NAME); |
455 | if (ret < 0) { | 339 | if (ret < 0) { |
456 | dev_err(dev, "remote input device register failed\n"); | 340 | dev_err(dev, "remote input device register failed\n"); |
457 | goto irdev_failed; | 341 | goto irdev_failed; |
@@ -467,29 +351,6 @@ idev_alloc_failed: | |||
467 | return NULL; | 351 | return NULL; |
468 | } | 352 | } |
469 | 353 | ||
470 | static int streamzap_delay_buf_init(struct streamzap_ir *sz) | ||
471 | { | ||
472 | int ret; | ||
473 | |||
474 | ret = kfifo_alloc(&sz->fifo, sizeof(int) * SZ_BUF_LEN, | ||
475 | GFP_KERNEL); | ||
476 | if (ret == 0) | ||
477 | sz->fifo_initialized = 1; | ||
478 | |||
479 | return ret; | ||
480 | } | ||
481 | |||
482 | static void streamzap_start_flush_timer(struct streamzap_ir *sz) | ||
483 | { | ||
484 | sz->flush_timer.expires = jiffies + HZ; | ||
485 | sz->flush = true; | ||
486 | add_timer(&sz->flush_timer); | ||
487 | |||
488 | sz->urb_in->dev = sz->usbdev; | ||
489 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) | ||
490 | dev_err(sz->dev, "urb submit failed\n"); | ||
491 | } | ||
492 | |||
493 | /** | 354 | /** |
494 | * streamzap_probe | 355 | * streamzap_probe |
495 | * | 356 | * |
@@ -575,35 +436,21 @@ static int __devinit streamzap_probe(struct usb_interface *intf, | |||
575 | snprintf(name + strlen(name), sizeof(name) - strlen(name), | 436 | snprintf(name + strlen(name), sizeof(name) - strlen(name), |
576 | " %s", buf); | 437 | " %s", buf); |
577 | 438 | ||
578 | retval = streamzap_delay_buf_init(sz); | ||
579 | if (retval) { | ||
580 | dev_err(&intf->dev, "%s: delay buffer init failed\n", __func__); | ||
581 | goto free_urb_in; | ||
582 | } | ||
583 | |||
584 | sz->idev = streamzap_init_input_dev(sz); | 439 | sz->idev = streamzap_init_input_dev(sz); |
585 | if (!sz->idev) | 440 | if (!sz->idev) |
586 | goto input_dev_fail; | 441 | goto input_dev_fail; |
587 | 442 | ||
588 | sz->idle = true; | 443 | sz->idle = true; |
589 | sz->decoder_state = PulseSpace; | 444 | sz->decoder_state = PulseSpace; |
445 | /* FIXME: don't yet have a way to set this */ | ||
446 | sz->timeout_enabled = true; | ||
590 | #if 0 | 447 | #if 0 |
591 | /* not yet supported, depends on patches from maxim */ | 448 | /* not yet supported, depends on patches from maxim */ |
592 | /* see also: LIRC_GET_REC_RESOLUTION and LIRC_SET_REC_TIMEOUT */ | 449 | /* see also: LIRC_GET_REC_RESOLUTION and LIRC_SET_REC_TIMEOUT */ |
593 | sz->timeout_enabled = false; | 450 | sz->min_timeout = SZ_TIMEOUT * SZ_RESOLUTION * 1000; |
594 | sz->min_timeout = STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION * 1000; | 451 | sz->max_timeout = SZ_TIMEOUT * SZ_RESOLUTION * 1000; |
595 | sz->max_timeout = STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION * 1000; | ||
596 | #endif | 452 | #endif |
597 | 453 | ||
598 | init_timer(&sz->delay_timer); | ||
599 | sz->delay_timer.function = streamzap_delay_timeout; | ||
600 | sz->delay_timer.data = (unsigned long)sz; | ||
601 | spin_lock_init(&sz->timer_lock); | ||
602 | |||
603 | init_timer(&sz->flush_timer); | ||
604 | sz->flush_timer.function = streamzap_flush_timeout; | ||
605 | sz->flush_timer.data = (unsigned long)sz; | ||
606 | |||
607 | do_gettimeofday(&sz->signal_start); | 454 | do_gettimeofday(&sz->signal_start); |
608 | 455 | ||
609 | /* Complete final initialisations */ | 456 | /* Complete final initialisations */ |
@@ -615,16 +462,18 @@ static int __devinit streamzap_probe(struct usb_interface *intf, | |||
615 | 462 | ||
616 | usb_set_intfdata(intf, sz); | 463 | usb_set_intfdata(intf, sz); |
617 | 464 | ||
618 | streamzap_start_flush_timer(sz); | 465 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) |
466 | dev_err(sz->dev, "urb submit failed\n"); | ||
619 | 467 | ||
620 | dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, | 468 | dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, |
621 | usbdev->bus->busnum, usbdev->devnum); | 469 | usbdev->bus->busnum, usbdev->devnum); |
622 | 470 | ||
471 | /* Load the streamzap not-quite-rc5 decoder too */ | ||
472 | load_rc5_sz_decode(); | ||
473 | |||
623 | return 0; | 474 | return 0; |
624 | 475 | ||
625 | input_dev_fail: | 476 | input_dev_fail: |
626 | kfifo_free(&sz->fifo); | ||
627 | free_urb_in: | ||
628 | usb_free_urb(sz->urb_in); | 477 | usb_free_urb(sz->urb_in); |
629 | free_buf_in: | 478 | free_buf_in: |
630 | usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); | 479 | usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); |
@@ -654,13 +503,6 @@ static void streamzap_disconnect(struct usb_interface *interface) | |||
654 | if (!sz) | 503 | if (!sz) |
655 | return; | 504 | return; |
656 | 505 | ||
657 | if (sz->flush) { | ||
658 | sz->flush = false; | ||
659 | del_timer_sync(&sz->flush_timer); | ||
660 | } | ||
661 | |||
662 | streamzap_stop_timer(sz); | ||
663 | |||
664 | sz->usbdev = NULL; | 506 | sz->usbdev = NULL; |
665 | ir_input_unregister(sz->idev); | 507 | ir_input_unregister(sz->idev); |
666 | usb_kill_urb(sz->urb_in); | 508 | usb_kill_urb(sz->urb_in); |
@@ -674,13 +516,6 @@ static int streamzap_suspend(struct usb_interface *intf, pm_message_t message) | |||
674 | { | 516 | { |
675 | struct streamzap_ir *sz = usb_get_intfdata(intf); | 517 | struct streamzap_ir *sz = usb_get_intfdata(intf); |
676 | 518 | ||
677 | if (sz->flush) { | ||
678 | sz->flush = false; | ||
679 | del_timer_sync(&sz->flush_timer); | ||
680 | } | ||
681 | |||
682 | streamzap_stop_timer(sz); | ||
683 | |||
684 | usb_kill_urb(sz->urb_in); | 519 | usb_kill_urb(sz->urb_in); |
685 | 520 | ||
686 | return 0; | 521 | return 0; |
@@ -690,13 +525,6 @@ static int streamzap_resume(struct usb_interface *intf) | |||
690 | { | 525 | { |
691 | struct streamzap_ir *sz = usb_get_intfdata(intf); | 526 | struct streamzap_ir *sz = usb_get_intfdata(intf); |
692 | 527 | ||
693 | if (sz->fifo_initialized) | ||
694 | kfifo_reset(&sz->fifo); | ||
695 | |||
696 | sz->flush_timer.expires = jiffies + HZ; | ||
697 | sz->flush = true; | ||
698 | add_timer(&sz->flush_timer); | ||
699 | |||
700 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { | 528 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { |
701 | dev_err(sz->dev, "Error sumbiting urb\n"); | 529 | dev_err(sz->dev, "Error sumbiting urb\n"); |
702 | return -EIO; | 530 | return -EIO; |