Lines Matching refs:sz
139 static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir) in sz_push() argument
141 dev_dbg(sz->dev, "Storing %s with duration %u us\n", in sz_push()
143 ir_raw_event_store_with_filter(sz->rdev, &rawir); in sz_push()
146 static void sz_push_full_pulse(struct streamzap_ir *sz, in sz_push_full_pulse() argument
151 if (sz->idle) { in sz_push_full_pulse()
154 sz->signal_last = sz->signal_start; in sz_push_full_pulse()
155 do_gettimeofday(&sz->signal_start); in sz_push_full_pulse()
157 deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; in sz_push_full_pulse()
164 sz->signal_start.tv_usec - in sz_push_full_pulse()
165 sz->signal_last.tv_usec); in sz_push_full_pulse()
166 rawir.duration -= sz->sum; in sz_push_full_pulse()
170 sz_push(sz, rawir); in sz_push_full_pulse()
172 sz->idle = false; in sz_push_full_pulse()
173 sz->sum = 0; in sz_push_full_pulse()
179 sz->sum += rawir.duration; in sz_push_full_pulse()
182 sz_push(sz, rawir); in sz_push_full_pulse()
185 static void sz_push_half_pulse(struct streamzap_ir *sz, in sz_push_half_pulse() argument
188 sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); in sz_push_half_pulse()
191 static void sz_push_full_space(struct streamzap_ir *sz, in sz_push_full_space() argument
199 sz->sum += rawir.duration; in sz_push_full_space()
201 sz_push(sz, rawir); in sz_push_full_space()
204 static void sz_push_half_space(struct streamzap_ir *sz, in sz_push_half_space() argument
207 sz_push_full_space(sz, value & SZ_SPACE_MASK); in sz_push_half_space()
218 struct streamzap_ir *sz; in streamzap_callback() local
225 sz = urb->context; in streamzap_callback()
236 dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); in streamzap_callback()
242 dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); in streamzap_callback()
244 dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", in streamzap_callback()
245 i, (unsigned char)sz->buf_in[i]); in streamzap_callback()
246 switch (sz->decoder_state) { in streamzap_callback()
248 if ((sz->buf_in[i] & SZ_PULSE_MASK) == in streamzap_callback()
250 sz->decoder_state = FullPulse; in streamzap_callback()
252 } else if ((sz->buf_in[i] & SZ_SPACE_MASK) in streamzap_callback()
254 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
255 sz->decoder_state = FullSpace; in streamzap_callback()
258 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
259 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
263 sz_push_full_pulse(sz, sz->buf_in[i]); in streamzap_callback()
264 sz->decoder_state = IgnorePulse; in streamzap_callback()
267 if (sz->buf_in[i] == SZ_TIMEOUT) { in streamzap_callback()
271 rawir.duration = sz->rdev->timeout; in streamzap_callback()
272 sz->idle = true; in streamzap_callback()
273 if (sz->timeout_enabled) in streamzap_callback()
274 sz_push(sz, rawir); in streamzap_callback()
275 ir_raw_event_handle(sz->rdev); in streamzap_callback()
276 ir_raw_event_reset(sz->rdev); in streamzap_callback()
278 sz_push_full_space(sz, sz->buf_in[i]); in streamzap_callback()
280 sz->decoder_state = PulseSpace; in streamzap_callback()
283 if ((sz->buf_in[i] & SZ_SPACE_MASK) == in streamzap_callback()
285 sz->decoder_state = FullSpace; in streamzap_callback()
288 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
289 sz->decoder_state = PulseSpace; in streamzap_callback()
294 ir_raw_event_handle(sz->rdev); in streamzap_callback()
300 static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) in streamzap_init_rc_dev() argument
303 struct device *dev = sz->dev; in streamzap_init_rc_dev()
312 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " in streamzap_init_rc_dev()
314 le16_to_cpu(sz->usbdev->descriptor.idVendor), in streamzap_init_rc_dev()
315 le16_to_cpu(sz->usbdev->descriptor.idProduct)); in streamzap_init_rc_dev()
316 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); in streamzap_init_rc_dev()
317 strlcat(sz->phys, "/input0", sizeof(sz->phys)); in streamzap_init_rc_dev()
319 rdev->input_name = sz->name; in streamzap_init_rc_dev()
320 rdev->input_phys = sz->phys; in streamzap_init_rc_dev()
321 usb_to_input_id(sz->usbdev, &rdev->input_id); in streamzap_init_rc_dev()
323 rdev->priv = sz; in streamzap_init_rc_dev()
354 struct streamzap_ir *sz = NULL; in streamzap_probe() local
360 sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); in streamzap_probe()
361 if (!sz) in streamzap_probe()
364 sz->usbdev = usbdev; in streamzap_probe()
365 sz->interface = intf; in streamzap_probe()
377 sz->endpoint = &(iface_host->endpoint[0].desc); in streamzap_probe()
378 if ((sz->endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) in streamzap_probe()
381 "02%02x\n", __func__, sz->endpoint->bEndpointAddress); in streamzap_probe()
386 if ((sz->endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) in streamzap_probe()
389 "02%02x\n", __func__, sz->endpoint->bmAttributes); in streamzap_probe()
394 pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); in streamzap_probe()
405 sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); in streamzap_probe()
406 if (!sz->buf_in) in streamzap_probe()
409 sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); in streamzap_probe()
410 if (!sz->urb_in) in streamzap_probe()
413 sz->dev = &intf->dev; in streamzap_probe()
414 sz->buf_in_len = maxp; in streamzap_probe()
427 sz->rdev = streamzap_init_rc_dev(sz); in streamzap_probe()
428 if (!sz->rdev) in streamzap_probe()
431 sz->idle = true; in streamzap_probe()
432 sz->decoder_state = PulseSpace; in streamzap_probe()
434 sz->timeout_enabled = true; in streamzap_probe()
435 sz->rdev->timeout = ((US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION) & in streamzap_probe()
440 sz->min_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
441 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
444 do_gettimeofday(&sz->signal_start); in streamzap_probe()
447 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, in streamzap_probe()
449 sz, sz->endpoint->bInterval); in streamzap_probe()
450 sz->urb_in->transfer_dma = sz->dma_in; in streamzap_probe()
451 sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in streamzap_probe()
453 usb_set_intfdata(intf, sz); in streamzap_probe()
455 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) in streamzap_probe()
456 dev_err(sz->dev, "urb submit failed\n"); in streamzap_probe()
458 dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, in streamzap_probe()
467 usb_free_urb(sz->urb_in); in streamzap_probe()
469 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); in streamzap_probe()
471 kfree(sz); in streamzap_probe()
488 struct streamzap_ir *sz = usb_get_intfdata(interface); in streamzap_disconnect() local
493 if (!sz) in streamzap_disconnect()
496 sz->usbdev = NULL; in streamzap_disconnect()
497 rc_unregister_device(sz->rdev); in streamzap_disconnect()
498 usb_kill_urb(sz->urb_in); in streamzap_disconnect()
499 usb_free_urb(sz->urb_in); in streamzap_disconnect()
500 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); in streamzap_disconnect()
502 kfree(sz); in streamzap_disconnect()
507 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_suspend() local
509 usb_kill_urb(sz->urb_in); in streamzap_suspend()
516 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_resume() local
518 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { in streamzap_resume()
519 dev_err(sz->dev, "Error sumbiting urb\n"); in streamzap_resume()