Lines Matching refs:sz
126 static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir) in sz_push() argument
128 dev_dbg(sz->dev, "Storing %s with duration %u us\n", in sz_push()
130 ir_raw_event_store_with_filter(sz->rdev, &rawir); in sz_push()
133 static void sz_push_full_pulse(struct streamzap_ir *sz, in sz_push_full_pulse() argument
138 if (sz->idle) { in sz_push_full_pulse()
141 sz->signal_last = sz->signal_start; in sz_push_full_pulse()
142 do_gettimeofday(&sz->signal_start); in sz_push_full_pulse()
144 deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; in sz_push_full_pulse()
151 sz->signal_start.tv_usec - in sz_push_full_pulse()
152 sz->signal_last.tv_usec); in sz_push_full_pulse()
153 rawir.duration -= sz->sum; in sz_push_full_pulse()
158 sz_push(sz, rawir); in sz_push_full_pulse()
160 sz->idle = false; in sz_push_full_pulse()
161 sz->sum = 0; in sz_push_full_pulse()
167 sz->sum += rawir.duration; in sz_push_full_pulse()
171 sz_push(sz, rawir); in sz_push_full_pulse()
174 static void sz_push_half_pulse(struct streamzap_ir *sz, in sz_push_half_pulse() argument
177 sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); in sz_push_half_pulse()
180 static void sz_push_full_space(struct streamzap_ir *sz, in sz_push_full_space() argument
188 sz->sum += rawir.duration; in sz_push_full_space()
190 sz_push(sz, rawir); in sz_push_full_space()
193 static void sz_push_half_space(struct streamzap_ir *sz, in sz_push_half_space() argument
196 sz_push_full_space(sz, value & SZ_SPACE_MASK); in sz_push_half_space()
207 struct streamzap_ir *sz; in streamzap_callback() local
214 sz = urb->context; in streamzap_callback()
225 dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); in streamzap_callback()
231 dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); in streamzap_callback()
233 dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", in streamzap_callback()
234 i, (unsigned char)sz->buf_in[i]); in streamzap_callback()
235 switch (sz->decoder_state) { in streamzap_callback()
237 if ((sz->buf_in[i] & SZ_PULSE_MASK) == in streamzap_callback()
239 sz->decoder_state = FullPulse; in streamzap_callback()
241 } else if ((sz->buf_in[i] & SZ_SPACE_MASK) in streamzap_callback()
243 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
244 sz->decoder_state = FullSpace; in streamzap_callback()
247 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
248 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
252 sz_push_full_pulse(sz, sz->buf_in[i]); in streamzap_callback()
253 sz->decoder_state = IgnorePulse; in streamzap_callback()
256 if (sz->buf_in[i] == SZ_TIMEOUT) { in streamzap_callback()
260 rawir.duration = sz->rdev->timeout; in streamzap_callback()
261 sz->idle = true; in streamzap_callback()
262 if (sz->timeout_enabled) in streamzap_callback()
263 sz_push(sz, rawir); in streamzap_callback()
264 ir_raw_event_handle(sz->rdev); in streamzap_callback()
265 ir_raw_event_reset(sz->rdev); in streamzap_callback()
267 sz_push_full_space(sz, sz->buf_in[i]); in streamzap_callback()
269 sz->decoder_state = PulseSpace; in streamzap_callback()
272 if ((sz->buf_in[i] & SZ_SPACE_MASK) == in streamzap_callback()
274 sz->decoder_state = FullSpace; in streamzap_callback()
277 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
278 sz->decoder_state = PulseSpace; in streamzap_callback()
283 ir_raw_event_handle(sz->rdev); in streamzap_callback()
289 static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) in streamzap_init_rc_dev() argument
292 struct device *dev = sz->dev; in streamzap_init_rc_dev()
301 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " in streamzap_init_rc_dev()
303 le16_to_cpu(sz->usbdev->descriptor.idVendor), in streamzap_init_rc_dev()
304 le16_to_cpu(sz->usbdev->descriptor.idProduct)); in streamzap_init_rc_dev()
305 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); in streamzap_init_rc_dev()
306 strlcat(sz->phys, "/input0", sizeof(sz->phys)); in streamzap_init_rc_dev()
308 rdev->input_name = sz->name; in streamzap_init_rc_dev()
309 rdev->input_phys = sz->phys; in streamzap_init_rc_dev()
310 usb_to_input_id(sz->usbdev, &rdev->input_id); in streamzap_init_rc_dev()
312 rdev->priv = sz; in streamzap_init_rc_dev()
343 struct streamzap_ir *sz = NULL; in streamzap_probe() local
349 sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); in streamzap_probe()
350 if (!sz) in streamzap_probe()
353 sz->usbdev = usbdev; in streamzap_probe()
354 sz->interface = intf; in streamzap_probe()
366 sz->endpoint = &(iface_host->endpoint[0].desc); in streamzap_probe()
367 if (!usb_endpoint_dir_in(sz->endpoint)) { in streamzap_probe()
369 "02%02x\n", __func__, sz->endpoint->bEndpointAddress); in streamzap_probe()
374 if (!usb_endpoint_xfer_int(sz->endpoint)) { in streamzap_probe()
376 "02%02x\n", __func__, sz->endpoint->bmAttributes); in streamzap_probe()
381 pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); in streamzap_probe()
392 sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); in streamzap_probe()
393 if (!sz->buf_in) in streamzap_probe()
396 sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); in streamzap_probe()
397 if (!sz->urb_in) in streamzap_probe()
400 sz->dev = &intf->dev; in streamzap_probe()
401 sz->buf_in_len = maxp; in streamzap_probe()
414 sz->rdev = streamzap_init_rc_dev(sz); in streamzap_probe()
415 if (!sz->rdev) in streamzap_probe()
418 sz->idle = true; in streamzap_probe()
419 sz->decoder_state = PulseSpace; in streamzap_probe()
421 sz->timeout_enabled = true; in streamzap_probe()
422 sz->rdev->timeout = ((US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION) & in streamzap_probe()
427 sz->min_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
428 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
431 do_gettimeofday(&sz->signal_start); in streamzap_probe()
434 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, in streamzap_probe()
436 sz, sz->endpoint->bInterval); in streamzap_probe()
437 sz->urb_in->transfer_dma = sz->dma_in; in streamzap_probe()
438 sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in streamzap_probe()
440 usb_set_intfdata(intf, sz); in streamzap_probe()
442 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) in streamzap_probe()
443 dev_err(sz->dev, "urb submit failed\n"); in streamzap_probe()
445 dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, in streamzap_probe()
451 usb_free_urb(sz->urb_in); in streamzap_probe()
453 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); in streamzap_probe()
455 kfree(sz); in streamzap_probe()
472 struct streamzap_ir *sz = usb_get_intfdata(interface); in streamzap_disconnect() local
477 if (!sz) in streamzap_disconnect()
480 sz->usbdev = NULL; in streamzap_disconnect()
481 rc_unregister_device(sz->rdev); in streamzap_disconnect()
482 usb_kill_urb(sz->urb_in); in streamzap_disconnect()
483 usb_free_urb(sz->urb_in); in streamzap_disconnect()
484 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); in streamzap_disconnect()
486 kfree(sz); in streamzap_disconnect()
491 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_suspend() local
493 usb_kill_urb(sz->urb_in); in streamzap_suspend()
500 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_resume() local
502 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { in streamzap_resume()
503 dev_err(sz->dev, "Error sumbiting urb\n"); in streamzap_resume()