Lines Matching refs:sz

114 static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)  in sz_push()  argument
116 dev_dbg(sz->dev, "Storing %s with duration %u us\n", in sz_push()
118 ir_raw_event_store_with_filter(sz->rdev, &rawir); in sz_push()
121 static void sz_push_full_pulse(struct streamzap_ir *sz, in sz_push_full_pulse() argument
126 if (sz->idle) { in sz_push_full_pulse()
129 sz->signal_last = sz->signal_start; in sz_push_full_pulse()
130 sz->signal_start = ktime_get_real(); in sz_push_full_pulse()
132 delta = ktime_us_delta(sz->signal_start, sz->signal_last); in sz_push_full_pulse()
139 rawir.duration -= sz->sum; in sz_push_full_pulse()
143 sz_push(sz, rawir); in sz_push_full_pulse()
145 sz->idle = false; in sz_push_full_pulse()
146 sz->sum = 0; in sz_push_full_pulse()
152 sz->sum += rawir.duration; in sz_push_full_pulse()
155 sz_push(sz, rawir); in sz_push_full_pulse()
158 static void sz_push_half_pulse(struct streamzap_ir *sz, in sz_push_half_pulse() argument
161 sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); in sz_push_half_pulse()
164 static void sz_push_full_space(struct streamzap_ir *sz, in sz_push_full_space() argument
172 sz->sum += rawir.duration; in sz_push_full_space()
173 sz_push(sz, rawir); in sz_push_full_space()
176 static void sz_push_half_space(struct streamzap_ir *sz, in sz_push_half_space() argument
179 sz_push_full_space(sz, value & SZ_SPACE_MASK); in sz_push_half_space()
190 struct streamzap_ir *sz; in streamzap_callback() local
197 sz = urb->context; in streamzap_callback()
208 dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); in streamzap_callback()
214 dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); in streamzap_callback()
216 dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", in streamzap_callback()
217 i, (unsigned char)sz->buf_in[i]); in streamzap_callback()
218 switch (sz->decoder_state) { in streamzap_callback()
220 if ((sz->buf_in[i] & SZ_PULSE_MASK) == in streamzap_callback()
222 sz->decoder_state = FullPulse; in streamzap_callback()
224 } else if ((sz->buf_in[i] & SZ_SPACE_MASK) in streamzap_callback()
226 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
227 sz->decoder_state = FullSpace; in streamzap_callback()
230 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
231 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
235 sz_push_full_pulse(sz, sz->buf_in[i]); in streamzap_callback()
236 sz->decoder_state = IgnorePulse; in streamzap_callback()
239 if (sz->buf_in[i] == SZ_TIMEOUT) { in streamzap_callback()
242 .duration = sz->rdev->timeout in streamzap_callback()
244 sz->idle = true; in streamzap_callback()
245 if (sz->timeout_enabled) in streamzap_callback()
246 sz_push(sz, rawir); in streamzap_callback()
247 ir_raw_event_handle(sz->rdev); in streamzap_callback()
248 ir_raw_event_reset(sz->rdev); in streamzap_callback()
250 sz_push_full_space(sz, sz->buf_in[i]); in streamzap_callback()
252 sz->decoder_state = PulseSpace; in streamzap_callback()
255 if ((sz->buf_in[i] & SZ_SPACE_MASK) == in streamzap_callback()
257 sz->decoder_state = FullSpace; in streamzap_callback()
260 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
261 sz->decoder_state = PulseSpace; in streamzap_callback()
266 ir_raw_event_handle(sz->rdev); in streamzap_callback()
270 static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) in streamzap_init_rc_dev() argument
273 struct device *dev = sz->dev; in streamzap_init_rc_dev()
282 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared Receiver (%04x:%04x)", in streamzap_init_rc_dev()
283 le16_to_cpu(sz->usbdev->descriptor.idVendor), in streamzap_init_rc_dev()
284 le16_to_cpu(sz->usbdev->descriptor.idProduct)); in streamzap_init_rc_dev()
285 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); in streamzap_init_rc_dev()
286 strlcat(sz->phys, "/input0", sizeof(sz->phys)); in streamzap_init_rc_dev()
288 rdev->device_name = sz->name; in streamzap_init_rc_dev()
289 rdev->input_phys = sz->phys; in streamzap_init_rc_dev()
290 usb_to_input_id(sz->usbdev, &rdev->input_id); in streamzap_init_rc_dev()
292 rdev->priv = sz; in streamzap_init_rc_dev()
323 struct streamzap_ir *sz = NULL; in streamzap_probe() local
329 sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); in streamzap_probe()
330 if (!sz) in streamzap_probe()
333 sz->usbdev = usbdev; in streamzap_probe()
334 sz->interface = intf; in streamzap_probe()
346 sz->endpoint = &(iface_host->endpoint[0].desc); in streamzap_probe()
347 if (!usb_endpoint_dir_in(sz->endpoint)) { in streamzap_probe()
349 __func__, sz->endpoint->bEndpointAddress); in streamzap_probe()
354 if (!usb_endpoint_xfer_int(sz->endpoint)) { in streamzap_probe()
356 __func__, sz->endpoint->bmAttributes); in streamzap_probe()
361 pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); in streamzap_probe()
372 sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); in streamzap_probe()
373 if (!sz->buf_in) in streamzap_probe()
376 sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); in streamzap_probe()
377 if (!sz->urb_in) in streamzap_probe()
380 sz->dev = &intf->dev; in streamzap_probe()
381 sz->buf_in_len = maxp; in streamzap_probe()
394 sz->rdev = streamzap_init_rc_dev(sz); in streamzap_probe()
395 if (!sz->rdev) in streamzap_probe()
398 sz->idle = true; in streamzap_probe()
399 sz->decoder_state = PulseSpace; in streamzap_probe()
401 sz->timeout_enabled = true; in streamzap_probe()
402 sz->rdev->timeout = SZ_TIMEOUT * SZ_RESOLUTION; in streamzap_probe()
406 sz->min_timeout = SZ_TIMEOUT * SZ_RESOLUTION; in streamzap_probe()
407 sz->max_timeout = SZ_TIMEOUT * SZ_RESOLUTION; in streamzap_probe()
410 sz->signal_start = ktime_get_real(); in streamzap_probe()
413 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, in streamzap_probe()
415 sz, sz->endpoint->bInterval); in streamzap_probe()
416 sz->urb_in->transfer_dma = sz->dma_in; in streamzap_probe()
417 sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in streamzap_probe()
419 usb_set_intfdata(intf, sz); in streamzap_probe()
421 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) in streamzap_probe()
422 dev_err(sz->dev, "urb submit failed\n"); in streamzap_probe()
424 dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, in streamzap_probe()
430 usb_free_urb(sz->urb_in); in streamzap_probe()
432 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); in streamzap_probe()
434 kfree(sz); in streamzap_probe()
451 struct streamzap_ir *sz = usb_get_intfdata(interface); in streamzap_disconnect() local
456 if (!sz) in streamzap_disconnect()
459 sz->usbdev = NULL; in streamzap_disconnect()
460 rc_unregister_device(sz->rdev); in streamzap_disconnect()
461 usb_kill_urb(sz->urb_in); in streamzap_disconnect()
462 usb_free_urb(sz->urb_in); in streamzap_disconnect()
463 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); in streamzap_disconnect()
465 kfree(sz); in streamzap_disconnect()
470 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_suspend() local
472 usb_kill_urb(sz->urb_in); in streamzap_suspend()
479 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_resume() local
481 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { in streamzap_resume()
482 dev_err(sz->dev, "Error submitting urb\n"); in streamzap_resume()