Lines Matching refs:sz

123 static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)  in sz_push()  argument
125 dev_dbg(sz->dev, "Storing %s with duration %u us\n", in sz_push()
127 ir_raw_event_store_with_filter(sz->rdev, &rawir); in sz_push()
130 static void sz_push_full_pulse(struct streamzap_ir *sz, in sz_push_full_pulse() argument
135 if (sz->idle) { in sz_push_full_pulse()
138 sz->signal_last = sz->signal_start; in sz_push_full_pulse()
139 sz->signal_start = ktime_get_real(); in sz_push_full_pulse()
141 delta = ktime_us_delta(sz->signal_start, sz->signal_last); in sz_push_full_pulse()
148 rawir.duration -= sz->sum; in sz_push_full_pulse()
153 sz_push(sz, rawir); in sz_push_full_pulse()
155 sz->idle = false; in sz_push_full_pulse()
156 sz->sum = 0; in sz_push_full_pulse()
162 sz->sum += rawir.duration; in sz_push_full_pulse()
166 sz_push(sz, rawir); in sz_push_full_pulse()
169 static void sz_push_half_pulse(struct streamzap_ir *sz, in sz_push_half_pulse() argument
172 sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); in sz_push_half_pulse()
175 static void sz_push_full_space(struct streamzap_ir *sz, in sz_push_full_space() argument
183 sz->sum += rawir.duration; in sz_push_full_space()
185 sz_push(sz, rawir); in sz_push_full_space()
188 static void sz_push_half_space(struct streamzap_ir *sz, in sz_push_half_space() argument
191 sz_push_full_space(sz, value & SZ_SPACE_MASK); in sz_push_half_space()
202 struct streamzap_ir *sz; in streamzap_callback() local
209 sz = urb->context; in streamzap_callback()
220 dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); in streamzap_callback()
226 dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); in streamzap_callback()
228 dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", in streamzap_callback()
229 i, (unsigned char)sz->buf_in[i]); in streamzap_callback()
230 switch (sz->decoder_state) { in streamzap_callback()
232 if ((sz->buf_in[i] & SZ_PULSE_MASK) == in streamzap_callback()
234 sz->decoder_state = FullPulse; in streamzap_callback()
236 } else if ((sz->buf_in[i] & SZ_SPACE_MASK) in streamzap_callback()
238 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
239 sz->decoder_state = FullSpace; in streamzap_callback()
242 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
243 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
247 sz_push_full_pulse(sz, sz->buf_in[i]); in streamzap_callback()
248 sz->decoder_state = IgnorePulse; in streamzap_callback()
251 if (sz->buf_in[i] == SZ_TIMEOUT) { in streamzap_callback()
255 rawir.duration = sz->rdev->timeout; in streamzap_callback()
256 sz->idle = true; in streamzap_callback()
257 if (sz->timeout_enabled) in streamzap_callback()
258 sz_push(sz, rawir); in streamzap_callback()
259 ir_raw_event_handle(sz->rdev); in streamzap_callback()
260 ir_raw_event_reset(sz->rdev); in streamzap_callback()
262 sz_push_full_space(sz, sz->buf_in[i]); in streamzap_callback()
264 sz->decoder_state = PulseSpace; in streamzap_callback()
267 if ((sz->buf_in[i] & SZ_SPACE_MASK) == in streamzap_callback()
269 sz->decoder_state = FullSpace; in streamzap_callback()
272 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
273 sz->decoder_state = PulseSpace; in streamzap_callback()
278 ir_raw_event_handle(sz->rdev); in streamzap_callback()
284 static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) in streamzap_init_rc_dev() argument
287 struct device *dev = sz->dev; in streamzap_init_rc_dev()
296 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared Receiver (%04x:%04x)", in streamzap_init_rc_dev()
297 le16_to_cpu(sz->usbdev->descriptor.idVendor), in streamzap_init_rc_dev()
298 le16_to_cpu(sz->usbdev->descriptor.idProduct)); in streamzap_init_rc_dev()
299 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); in streamzap_init_rc_dev()
300 strlcat(sz->phys, "/input0", sizeof(sz->phys)); in streamzap_init_rc_dev()
302 rdev->device_name = sz->name; in streamzap_init_rc_dev()
303 rdev->input_phys = sz->phys; in streamzap_init_rc_dev()
304 usb_to_input_id(sz->usbdev, &rdev->input_id); in streamzap_init_rc_dev()
306 rdev->priv = sz; in streamzap_init_rc_dev()
336 struct streamzap_ir *sz = NULL; in streamzap_probe() local
342 sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); in streamzap_probe()
343 if (!sz) in streamzap_probe()
346 sz->usbdev = usbdev; in streamzap_probe()
347 sz->interface = intf; in streamzap_probe()
359 sz->endpoint = &(iface_host->endpoint[0].desc); in streamzap_probe()
360 if (!usb_endpoint_dir_in(sz->endpoint)) { in streamzap_probe()
362 __func__, sz->endpoint->bEndpointAddress); in streamzap_probe()
367 if (!usb_endpoint_xfer_int(sz->endpoint)) { in streamzap_probe()
369 __func__, sz->endpoint->bmAttributes); in streamzap_probe()
374 pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); in streamzap_probe()
385 sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); in streamzap_probe()
386 if (!sz->buf_in) in streamzap_probe()
389 sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); in streamzap_probe()
390 if (!sz->urb_in) in streamzap_probe()
393 sz->dev = &intf->dev; in streamzap_probe()
394 sz->buf_in_len = maxp; in streamzap_probe()
407 sz->rdev = streamzap_init_rc_dev(sz); in streamzap_probe()
408 if (!sz->rdev) in streamzap_probe()
411 sz->idle = true; in streamzap_probe()
412 sz->decoder_state = PulseSpace; in streamzap_probe()
414 sz->timeout_enabled = true; in streamzap_probe()
415 sz->rdev->timeout = ((US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION) & in streamzap_probe()
420 sz->min_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
421 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
424 sz->signal_start = ktime_get_real(); in streamzap_probe()
427 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, in streamzap_probe()
429 sz, sz->endpoint->bInterval); in streamzap_probe()
430 sz->urb_in->transfer_dma = sz->dma_in; in streamzap_probe()
431 sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in streamzap_probe()
433 usb_set_intfdata(intf, sz); in streamzap_probe()
435 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) in streamzap_probe()
436 dev_err(sz->dev, "urb submit failed\n"); in streamzap_probe()
438 dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, in streamzap_probe()
444 usb_free_urb(sz->urb_in); in streamzap_probe()
446 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); in streamzap_probe()
448 kfree(sz); in streamzap_probe()
465 struct streamzap_ir *sz = usb_get_intfdata(interface); in streamzap_disconnect() local
470 if (!sz) in streamzap_disconnect()
473 sz->usbdev = NULL; in streamzap_disconnect()
474 rc_unregister_device(sz->rdev); in streamzap_disconnect()
475 usb_kill_urb(sz->urb_in); in streamzap_disconnect()
476 usb_free_urb(sz->urb_in); in streamzap_disconnect()
477 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); in streamzap_disconnect()
479 kfree(sz); in streamzap_disconnect()
484 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_suspend() local
486 usb_kill_urb(sz->urb_in); in streamzap_suspend()
493 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_resume() local
495 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { in streamzap_resume()
496 dev_err(sz->dev, "Error submitting urb\n"); in streamzap_resume()