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()
157 sz_push(sz, rawir); in sz_push_full_pulse()
159 sz->idle = false; in sz_push_full_pulse()
160 sz->sum = 0; in sz_push_full_pulse()
166 sz->sum += rawir.duration; in sz_push_full_pulse()
169 sz_push(sz, rawir); in sz_push_full_pulse()
172 static void sz_push_half_pulse(struct streamzap_ir *sz, in sz_push_half_pulse() argument
175 sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); in sz_push_half_pulse()
178 static void sz_push_full_space(struct streamzap_ir *sz, in sz_push_full_space() argument
186 sz->sum += rawir.duration; in sz_push_full_space()
188 sz_push(sz, rawir); in sz_push_full_space()
191 static void sz_push_half_space(struct streamzap_ir *sz, in sz_push_half_space() argument
194 sz_push_full_space(sz, value & SZ_SPACE_MASK); in sz_push_half_space()
205 struct streamzap_ir *sz; in streamzap_callback() local
212 sz = urb->context; in streamzap_callback()
223 dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); in streamzap_callback()
229 dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); in streamzap_callback()
231 dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", in streamzap_callback()
232 i, (unsigned char)sz->buf_in[i]); in streamzap_callback()
233 switch (sz->decoder_state) { in streamzap_callback()
235 if ((sz->buf_in[i] & SZ_PULSE_MASK) == in streamzap_callback()
237 sz->decoder_state = FullPulse; in streamzap_callback()
239 } else if ((sz->buf_in[i] & SZ_SPACE_MASK) in streamzap_callback()
241 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
242 sz->decoder_state = FullSpace; in streamzap_callback()
245 sz_push_half_pulse(sz, sz->buf_in[i]); in streamzap_callback()
246 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
250 sz_push_full_pulse(sz, sz->buf_in[i]); in streamzap_callback()
251 sz->decoder_state = IgnorePulse; in streamzap_callback()
254 if (sz->buf_in[i] == SZ_TIMEOUT) { in streamzap_callback()
258 rawir.duration = sz->rdev->timeout; in streamzap_callback()
259 sz->idle = true; in streamzap_callback()
260 if (sz->timeout_enabled) in streamzap_callback()
261 sz_push(sz, rawir); in streamzap_callback()
262 ir_raw_event_handle(sz->rdev); in streamzap_callback()
263 ir_raw_event_reset(sz->rdev); in streamzap_callback()
265 sz_push_full_space(sz, sz->buf_in[i]); in streamzap_callback()
267 sz->decoder_state = PulseSpace; in streamzap_callback()
270 if ((sz->buf_in[i] & SZ_SPACE_MASK) == in streamzap_callback()
272 sz->decoder_state = FullSpace; in streamzap_callback()
275 sz_push_half_space(sz, sz->buf_in[i]); in streamzap_callback()
276 sz->decoder_state = PulseSpace; in streamzap_callback()
281 ir_raw_event_handle(sz->rdev); in streamzap_callback()
287 static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) in streamzap_init_rc_dev() argument
290 struct device *dev = sz->dev; in streamzap_init_rc_dev()
299 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " in streamzap_init_rc_dev()
301 le16_to_cpu(sz->usbdev->descriptor.idVendor), in streamzap_init_rc_dev()
302 le16_to_cpu(sz->usbdev->descriptor.idProduct)); in streamzap_init_rc_dev()
303 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); in streamzap_init_rc_dev()
304 strlcat(sz->phys, "/input0", sizeof(sz->phys)); in streamzap_init_rc_dev()
306 rdev->input_name = sz->name; in streamzap_init_rc_dev()
307 rdev->input_phys = sz->phys; in streamzap_init_rc_dev()
308 usb_to_input_id(sz->usbdev, &rdev->input_id); in streamzap_init_rc_dev()
310 rdev->priv = sz; in streamzap_init_rc_dev()
341 struct streamzap_ir *sz = NULL; in streamzap_probe() local
347 sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); in streamzap_probe()
348 if (!sz) in streamzap_probe()
351 sz->usbdev = usbdev; in streamzap_probe()
352 sz->interface = intf; in streamzap_probe()
364 sz->endpoint = &(iface_host->endpoint[0].desc); in streamzap_probe()
365 if (!usb_endpoint_dir_in(sz->endpoint)) { in streamzap_probe()
367 "02%02x\n", __func__, sz->endpoint->bEndpointAddress); in streamzap_probe()
372 if (!usb_endpoint_xfer_int(sz->endpoint)) { in streamzap_probe()
374 "02%02x\n", __func__, sz->endpoint->bmAttributes); in streamzap_probe()
379 pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); in streamzap_probe()
390 sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); in streamzap_probe()
391 if (!sz->buf_in) in streamzap_probe()
394 sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); in streamzap_probe()
395 if (!sz->urb_in) in streamzap_probe()
398 sz->dev = &intf->dev; in streamzap_probe()
399 sz->buf_in_len = maxp; in streamzap_probe()
412 sz->rdev = streamzap_init_rc_dev(sz); in streamzap_probe()
413 if (!sz->rdev) in streamzap_probe()
416 sz->idle = true; in streamzap_probe()
417 sz->decoder_state = PulseSpace; in streamzap_probe()
419 sz->timeout_enabled = true; in streamzap_probe()
420 sz->rdev->timeout = ((US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION) & in streamzap_probe()
425 sz->min_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
426 sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); in streamzap_probe()
429 do_gettimeofday(&sz->signal_start); in streamzap_probe()
432 usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, in streamzap_probe()
434 sz, sz->endpoint->bInterval); in streamzap_probe()
435 sz->urb_in->transfer_dma = sz->dma_in; in streamzap_probe()
436 sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in streamzap_probe()
438 usb_set_intfdata(intf, sz); in streamzap_probe()
440 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) in streamzap_probe()
441 dev_err(sz->dev, "urb submit failed\n"); in streamzap_probe()
443 dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, in streamzap_probe()
449 usb_free_urb(sz->urb_in); in streamzap_probe()
451 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); in streamzap_probe()
453 kfree(sz); in streamzap_probe()
470 struct streamzap_ir *sz = usb_get_intfdata(interface); in streamzap_disconnect() local
475 if (!sz) in streamzap_disconnect()
478 sz->usbdev = NULL; in streamzap_disconnect()
479 rc_unregister_device(sz->rdev); in streamzap_disconnect()
480 usb_kill_urb(sz->urb_in); in streamzap_disconnect()
481 usb_free_urb(sz->urb_in); in streamzap_disconnect()
482 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); in streamzap_disconnect()
484 kfree(sz); in streamzap_disconnect()
489 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_suspend() local
491 usb_kill_urb(sz->urb_in); in streamzap_suspend()
498 struct streamzap_ir *sz = usb_get_intfdata(intf); in streamzap_resume() local
500 if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { in streamzap_resume()
501 dev_err(sz->dev, "Error sumbiting urb\n"); in streamzap_resume()