Lines Matching refs:dev

45 static inline v4l2_std_id vivid_get_std_cap(const struct vivid_dev *dev)  in vivid_get_std_cap()  argument
47 if (vivid_is_sdtv_cap(dev)) in vivid_get_std_cap()
48 return dev->std_cap[dev->input]; in vivid_get_std_cap()
52 static void copy_pix(struct vivid_dev *dev, int win_y, int win_x, in copy_pix() argument
60 if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_CHROMAKEY) && in copy_pix()
61 *osd != dev->chromakey_out) in copy_pix()
63 if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_SRC_CHROMAKEY) && in copy_pix()
64 out == dev->chromakey_out) in copy_pix()
66 if (dev->fmt_cap->alpha_mask) { in copy_pix()
67 if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) && in copy_pix()
68 dev->global_alpha_out) in copy_pix()
70 if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) && in copy_pix()
71 *cap & dev->fmt_cap->alpha_mask) in copy_pix()
73 if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_LOCAL_INV_ALPHA) && in copy_pix()
74 !(*cap & dev->fmt_cap->alpha_mask)) in copy_pix()
80 static void blend_line(struct vivid_dev *dev, unsigned y_offset, unsigned x_offset, in blend_line() argument
87 copy_pix(dev, y_offset, x_offset + x, in blend_line()
145 static void vivid_precalc_copy_rects(struct vivid_dev *dev) in vivid_precalc_copy_rects() argument
149 0, 0, dev->display_width, dev->display_height in vivid_precalc_copy_rects()
153 dev->overlay_out_left, dev->overlay_out_top, in vivid_precalc_copy_rects()
154 dev->compose_out.width, dev->compose_out.height in vivid_precalc_copy_rects()
157 v4l2_rect_intersect(&dev->loop_vid_copy, &dev->crop_cap, &dev->compose_out); in vivid_precalc_copy_rects()
159 dev->loop_vid_out = dev->loop_vid_copy; in vivid_precalc_copy_rects()
160 v4l2_rect_scale(&dev->loop_vid_out, &dev->compose_out, &dev->crop_out); in vivid_precalc_copy_rects()
161 dev->loop_vid_out.left += dev->crop_out.left; in vivid_precalc_copy_rects()
162 dev->loop_vid_out.top += dev->crop_out.top; in vivid_precalc_copy_rects()
164 dev->loop_vid_cap = dev->loop_vid_copy; in vivid_precalc_copy_rects()
165 v4l2_rect_scale(&dev->loop_vid_cap, &dev->crop_cap, &dev->compose_cap); in vivid_precalc_copy_rects()
167 dprintk(dev, 1, in vivid_precalc_copy_rects()
169 dev->loop_vid_copy.width, dev->loop_vid_copy.height, in vivid_precalc_copy_rects()
170 dev->loop_vid_copy.left, dev->loop_vid_copy.top, in vivid_precalc_copy_rects()
171 dev->loop_vid_out.width, dev->loop_vid_out.height, in vivid_precalc_copy_rects()
172 dev->loop_vid_out.left, dev->loop_vid_out.top, in vivid_precalc_copy_rects()
173 dev->loop_vid_cap.width, dev->loop_vid_cap.height, in vivid_precalc_copy_rects()
174 dev->loop_vid_cap.left, dev->loop_vid_cap.top); in vivid_precalc_copy_rects()
179 r_overlay.left += dev->compose_out.left - dev->overlay_out_left; in vivid_precalc_copy_rects()
180 r_overlay.top += dev->compose_out.top - dev->overlay_out_top; in vivid_precalc_copy_rects()
182 v4l2_rect_intersect(&dev->loop_vid_overlay, &r_overlay, &dev->loop_vid_copy); in vivid_precalc_copy_rects()
183 dev->loop_fb_copy = dev->loop_vid_overlay; in vivid_precalc_copy_rects()
186 dev->loop_fb_copy.left -= dev->compose_out.left - dev->overlay_out_left; in vivid_precalc_copy_rects()
187 dev->loop_fb_copy.top -= dev->compose_out.top - dev->overlay_out_top; in vivid_precalc_copy_rects()
189 dev->loop_vid_overlay_cap = dev->loop_vid_overlay; in vivid_precalc_copy_rects()
190 v4l2_rect_scale(&dev->loop_vid_overlay_cap, &dev->crop_cap, &dev->compose_cap); in vivid_precalc_copy_rects()
192 dprintk(dev, 1, in vivid_precalc_copy_rects()
194 dev->loop_fb_copy.width, dev->loop_fb_copy.height, in vivid_precalc_copy_rects()
195 dev->loop_fb_copy.left, dev->loop_fb_copy.top, in vivid_precalc_copy_rects()
196 dev->loop_vid_overlay.width, dev->loop_vid_overlay.height, in vivid_precalc_copy_rects()
197 dev->loop_vid_overlay.left, dev->loop_vid_overlay.top, in vivid_precalc_copy_rects()
198 dev->loop_vid_overlay_cap.width, dev->loop_vid_overlay_cap.height, in vivid_precalc_copy_rects()
199 dev->loop_vid_overlay_cap.left, dev->loop_vid_overlay_cap.top); in vivid_precalc_copy_rects()
216 static noinline_for_stack int vivid_copy_buffer(struct vivid_dev *dev, unsigned p, in vivid_copy_buffer() argument
219 bool blank = dev->must_blank[vid_cap_buf->vb.vb2_buf.index]; in vivid_copy_buffer()
220 struct tpg_data *tpg = &dev->tpg; in vivid_copy_buffer()
222 unsigned vdiv = dev->fmt_out->vdownsampling[p]; in vivid_copy_buffer()
224 unsigned img_width = tpg_hdiv(tpg, p, dev->compose_cap.width); in vivid_copy_buffer()
225 unsigned img_height = dev->compose_cap.height; in vivid_copy_buffer()
227 unsigned stride_out = dev->bytesperline_out[p]; in vivid_copy_buffer()
228 unsigned stride_osd = dev->display_byte_stride; in vivid_copy_buffer()
233 bool blend = dev->fbuf_out_flags; in vivid_copy_buffer()
243 unsigned vid_cap_left = tpg_hdiv(tpg, p, dev->loop_vid_cap.left); in vivid_copy_buffer()
247 vid_out_int_part = dev->loop_vid_out.height / dev->loop_vid_cap.height; in vivid_copy_buffer()
248 vid_out_fract_part = dev->loop_vid_out.height % dev->loop_vid_cap.height; in vivid_copy_buffer()
250 if (!list_empty(&dev->vid_out_active)) in vivid_copy_buffer()
251 vid_out_buf = list_entry(dev->vid_out_active.next, in vivid_copy_buffer()
259 dev->bytesperline_out, dev->fmt_out_rect.height); in vivid_copy_buffer()
260 if (p < dev->fmt_out->buffers) in vivid_copy_buffer()
262 voutbuf += tpg_hdiv(tpg, p, dev->loop_vid_out.left) + in vivid_copy_buffer()
263 (dev->loop_vid_out.top / vdiv) * stride_out; in vivid_copy_buffer()
264 vcapbuf += tpg_hdiv(tpg, p, dev->compose_cap.left) + in vivid_copy_buffer()
265 (dev->compose_cap.top / vdiv) * stride_cap; in vivid_copy_buffer()
267 if (dev->loop_vid_copy.width == 0 || dev->loop_vid_copy.height == 0) { in vivid_copy_buffer()
277 if (dev->overlay_out_enabled && in vivid_copy_buffer()
278 dev->loop_vid_overlay.width && dev->loop_vid_overlay.height) { in vivid_copy_buffer()
279 vosdbuf = dev->video_vbase; in vivid_copy_buffer()
280 vosdbuf += (dev->loop_fb_copy.left * twopixsize) / 2 + in vivid_copy_buffer()
281 dev->loop_fb_copy.top * stride_osd; in vivid_copy_buffer()
282 vid_overlay_int_part = dev->loop_vid_overlay.height / in vivid_copy_buffer()
283 dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
284 vid_overlay_fract_part = dev->loop_vid_overlay.height % in vivid_copy_buffer()
285 dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
288 vid_cap_right = tpg_hdiv(tpg, p, dev->loop_vid_cap.left + dev->loop_vid_cap.width); in vivid_copy_buffer()
290 quick = dev->loop_vid_out.width == dev->loop_vid_cap.width; in vivid_copy_buffer()
292 dev->cur_scaled_line = dev->loop_vid_out.height; in vivid_copy_buffer()
295 bool osdline = vosdbuf && y >= dev->loop_vid_overlay_cap.top && in vivid_copy_buffer()
296 y < dev->loop_vid_overlay_cap.top + dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
302 if (y < dev->loop_vid_cap.top || in vivid_copy_buffer()
303 y >= dev->loop_vid_cap.top + dev->loop_vid_cap.height) { in vivid_copy_buffer()
309 if (dev->loop_vid_cap.left) in vivid_copy_buffer()
320 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
323 if (dev->cur_scaled_line == vid_out_y) { in vivid_copy_buffer()
324 memcpy(vcapbuf + vid_cap_left, dev->scaled_line, in vivid_copy_buffer()
325 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
329 scale_line(voutbuf + vid_out_y * stride_out, dev->scaled_line, in vivid_copy_buffer()
330 tpg_hdiv(tpg, p, dev->loop_vid_out.width), in vivid_copy_buffer()
331 tpg_hdiv(tpg, p, dev->loop_vid_cap.width), in vivid_copy_buffer()
339 ((dev->loop_vid_overlay.left - dev->loop_vid_copy.left) * in vivid_copy_buffer()
343 scale_line(voutbuf + vid_out_y * stride_out, dev->blended_line, in vivid_copy_buffer()
344 dev->loop_vid_out.width, dev->loop_vid_copy.width, in vivid_copy_buffer()
347 blend_line(dev, vid_overlay_y + dev->loop_vid_overlay.top, in vivid_copy_buffer()
348 dev->loop_vid_overlay.left, in vivid_copy_buffer()
349 dev->blended_line + offset, osd, in vivid_copy_buffer()
350 dev->loop_vid_overlay.width, twopixsize / 2); in vivid_copy_buffer()
352 memcpy(dev->blended_line + offset, in vivid_copy_buffer()
353 osd, (dev->loop_vid_overlay.width * twopixsize) / 2); in vivid_copy_buffer()
354 scale_line(dev->blended_line, dev->scaled_line, in vivid_copy_buffer()
355 dev->loop_vid_copy.width, dev->loop_vid_cap.width, in vivid_copy_buffer()
358 dev->cur_scaled_line = vid_out_y; in vivid_copy_buffer()
359 memcpy(vcapbuf + vid_cap_left, dev->scaled_line, in vivid_copy_buffer()
360 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
366 if (vid_overlay_error >= dev->loop_vid_overlay_cap.height) { in vivid_copy_buffer()
367 vid_overlay_error -= dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
373 if (vid_out_error >= dev->loop_vid_cap.height / vdiv) { in vivid_copy_buffer()
374 vid_out_error -= dev->loop_vid_cap.height / vdiv; in vivid_copy_buffer()
386 static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf) in vivid_fillbuff() argument
388 struct tpg_data *tpg = &dev->tpg; in vivid_fillbuff()
389 unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_cap) ? 2 : 1; in vivid_fillbuff()
391 bool is_tv = vivid_is_sdtv_cap(dev); in vivid_fillbuff()
392 bool is_60hz = is_tv && (dev->std_cap[dev->input] & V4L2_STD_525_60); in vivid_fillbuff()
401 if (dev->loop_video && dev->can_loop_video && in vivid_fillbuff()
402 ((vivid_is_svid_cap(dev) && in vivid_fillbuff()
403 !VIVID_INVALID_SIGNAL(dev->std_signal_mode[dev->input])) || in vivid_fillbuff()
404 (vivid_is_hdmi_cap(dev) && in vivid_fillbuff()
405 !VIVID_INVALID_SIGNAL(dev->dv_timings_signal_mode[dev->input])))) in vivid_fillbuff()
408 buf->vb.sequence = dev->vid_cap_seq_count; in vivid_fillbuff()
409 v4l2_ctrl_s_ctrl(dev->ro_int32, buf->vb.sequence & 0xff); in vivid_fillbuff()
410 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { in vivid_fillbuff()
417 buf->vb.field = ((dev->vid_cap_seq_count & 1) ^ is_60hz) ? in vivid_fillbuff()
425 buf->vb.field = dev->field_cap; in vivid_fillbuff()
428 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_fillbuff()
429 tpg_s_perc_fill_blank(tpg, dev->must_blank[buf->vb.vb2_buf.index]); in vivid_fillbuff()
431 vivid_precalc_copy_rects(dev); in vivid_fillbuff()
442 if (p < tpg_g_buffers(tpg) && dev->fmt_cap->data_offset[p]) { in vivid_fillbuff()
443 memset(vbuf, dev->fmt_cap->data_offset[p] & 0xff, in vivid_fillbuff()
444 dev->fmt_cap->data_offset[p]); in vivid_fillbuff()
445 vbuf += dev->fmt_cap->data_offset[p]; in vivid_fillbuff()
448 if (!is_loop || vivid_copy_buffer(dev, p, vbuf, buf)) in vivid_fillbuff()
449 tpg_fill_plane_buffer(tpg, vivid_get_std_cap(dev), in vivid_fillbuff()
452 dev->must_blank[buf->vb.vb2_buf.index] = false; in vivid_fillbuff()
455 if (dev->field_cap != V4L2_FIELD_ALTERNATE || in vivid_fillbuff()
456 (dev->vid_cap_seq_count & 1) == 0) in vivid_fillbuff()
457 dev->ms_vid_cap = in vivid_fillbuff()
458 jiffies_to_msecs(jiffies - dev->jiffies_vid_cap); in vivid_fillbuff()
460 ms = dev->ms_vid_cap; in vivid_fillbuff()
461 if (dev->osd_mode <= 1) { in vivid_fillbuff()
468 (dev->field_cap == V4L2_FIELD_ALTERNATE) ? in vivid_fillbuff()
473 if (dev->osd_mode == 0) { in vivid_fillbuff()
475 dev->src_rect.width, dev->src_rect.height, dev->input); in vivid_fillbuff()
478 gain = v4l2_ctrl_g_ctrl(dev->gain); in vivid_fillbuff()
479 mutex_lock(dev->ctrl_hdl_user_vid.lock); in vivid_fillbuff()
482 dev->brightness->cur.val, in vivid_fillbuff()
483 dev->contrast->cur.val, in vivid_fillbuff()
484 dev->saturation->cur.val, in vivid_fillbuff()
485 dev->hue->cur.val); in vivid_fillbuff()
489 dev->autogain->cur.val, gain, dev->alpha->cur.val); in vivid_fillbuff()
490 mutex_unlock(dev->ctrl_hdl_user_vid.lock); in vivid_fillbuff()
492 mutex_lock(dev->ctrl_hdl_user_aud.lock); in vivid_fillbuff()
495 dev->volume->cur.val, dev->mute->cur.val); in vivid_fillbuff()
496 mutex_unlock(dev->ctrl_hdl_user_aud.lock); in vivid_fillbuff()
498 mutex_lock(dev->ctrl_hdl_user_gen.lock); in vivid_fillbuff()
500 dev->int32->cur.val, in vivid_fillbuff()
501 dev->ro_int32->cur.val, in vivid_fillbuff()
502 *dev->int64->p_cur.p_s64, in vivid_fillbuff()
503 dev->bitmask->cur.val); in vivid_fillbuff()
506 dev->boolean->cur.val, in vivid_fillbuff()
507 dev->menu->qmenu[dev->menu->cur.val], in vivid_fillbuff()
508 dev->string->p_cur.p_char); in vivid_fillbuff()
511 dev->int_menu->qmenu_int[dev->int_menu->cur.val], in vivid_fillbuff()
512 dev->int_menu->cur.val); in vivid_fillbuff()
513 mutex_unlock(dev->ctrl_hdl_user_gen.lock); in vivid_fillbuff()
515 if (dev->button_pressed) { in vivid_fillbuff()
516 dev->button_pressed--; in vivid_fillbuff()
520 if (dev->osd[0]) { in vivid_fillbuff()
521 if (vivid_is_hdmi_cap(dev)) { in vivid_fillbuff()
523 " OSD \"%s\"", dev->osd); in vivid_fillbuff()
527 if (dev->osd_jiffies && in vivid_fillbuff()
528 time_is_before_jiffies(dev->osd_jiffies + 5 * HZ)) { in vivid_fillbuff()
529 dev->osd[0] = 0; in vivid_fillbuff()
530 dev->osd_jiffies = 0; in vivid_fillbuff()
536 static void vivid_cap_update_frame_period(struct vivid_dev *dev) in vivid_cap_update_frame_period() argument
540 f_period = (u64)dev->timeperframe_vid_cap.numerator * 1000000000; in vivid_cap_update_frame_period()
541 if (WARN_ON(dev->timeperframe_vid_cap.denominator == 0)) in vivid_cap_update_frame_period()
542 dev->timeperframe_vid_cap.denominator = 1; in vivid_cap_update_frame_period()
543 do_div(f_period, dev->timeperframe_vid_cap.denominator); in vivid_cap_update_frame_period()
544 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_cap_update_frame_period()
550 dev->cap_frame_eof_offset = f_period * 9; in vivid_cap_update_frame_period()
551 do_div(dev->cap_frame_eof_offset, 10); in vivid_cap_update_frame_period()
552 dev->cap_frame_period = f_period; in vivid_cap_update_frame_period()
555 static noinline_for_stack void vivid_thread_vid_cap_tick(struct vivid_dev *dev, in vivid_thread_vid_cap_tick() argument
563 dprintk(dev, 1, "Video Capture Thread Tick\n"); in vivid_thread_vid_cap_tick()
566 tpg_update_mv_count(&dev->tpg, in vivid_thread_vid_cap_tick()
567 dev->field_cap == V4L2_FIELD_NONE || in vivid_thread_vid_cap_tick()
568 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_thread_vid_cap_tick()
571 if (dev->perc_dropped_buffers && in vivid_thread_vid_cap_tick()
572 get_random_u32_below(100) < dev->perc_dropped_buffers) in vivid_thread_vid_cap_tick()
575 spin_lock(&dev->slock); in vivid_thread_vid_cap_tick()
576 if (!list_empty(&dev->vid_cap_active)) { in vivid_thread_vid_cap_tick()
577 vid_cap_buf = list_entry(dev->vid_cap_active.next, struct vivid_buffer, list); in vivid_thread_vid_cap_tick()
580 if (!list_empty(&dev->vbi_cap_active)) { in vivid_thread_vid_cap_tick()
581 if (dev->field_cap != V4L2_FIELD_ALTERNATE || in vivid_thread_vid_cap_tick()
582 (dev->vbi_cap_seq_count & 1)) { in vivid_thread_vid_cap_tick()
583 vbi_cap_buf = list_entry(dev->vbi_cap_active.next, in vivid_thread_vid_cap_tick()
588 if (!list_empty(&dev->meta_cap_active)) { in vivid_thread_vid_cap_tick()
589 meta_cap_buf = list_entry(dev->meta_cap_active.next, in vivid_thread_vid_cap_tick()
594 spin_unlock(&dev->slock); in vivid_thread_vid_cap_tick()
599 f_time = ktime_get_ns() + dev->time_wrap_offset; in vivid_thread_vid_cap_tick()
603 &dev->ctrl_hdl_vid_cap); in vivid_thread_vid_cap_tick()
605 vivid_fillbuff(dev, vid_cap_buf); in vivid_thread_vid_cap_tick()
606 dprintk(dev, 1, "filled buffer %d\n", in vivid_thread_vid_cap_tick()
610 &dev->ctrl_hdl_vid_cap); in vivid_thread_vid_cap_tick()
611 vb2_buffer_done(&vid_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
613 dprintk(dev, 2, "vid_cap buffer %d done\n", in vivid_thread_vid_cap_tick()
617 if (!dev->tstamp_src_is_soe) in vivid_thread_vid_cap_tick()
618 vid_cap_buf->vb.vb2_buf.timestamp += dev->cap_frame_eof_offset; in vivid_thread_vid_cap_tick()
625 &dev->ctrl_hdl_vbi_cap); in vivid_thread_vid_cap_tick()
627 vivid_sliced_vbi_cap_process(dev, vbi_cap_buf); in vivid_thread_vid_cap_tick()
629 vivid_raw_vbi_cap_process(dev, vbi_cap_buf); in vivid_thread_vid_cap_tick()
631 &dev->ctrl_hdl_vbi_cap); in vivid_thread_vid_cap_tick()
632 vb2_buffer_done(&vbi_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
634 dprintk(dev, 2, "vbi_cap %d done\n", in vivid_thread_vid_cap_tick()
638 vbi_period = dev->cap_frame_period * 5; in vivid_thread_vid_cap_tick()
640 vbi_cap_buf->vb.vb2_buf.timestamp = f_time + dev->cap_frame_eof_offset + vbi_period; in vivid_thread_vid_cap_tick()
645 &dev->ctrl_hdl_meta_cap); in vivid_thread_vid_cap_tick()
646 vivid_meta_cap_fillbuff(dev, meta_cap_buf, f_time); in vivid_thread_vid_cap_tick()
648 &dev->ctrl_hdl_meta_cap); in vivid_thread_vid_cap_tick()
649 vb2_buffer_done(&meta_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
651 dprintk(dev, 2, "meta_cap %d done\n", in vivid_thread_vid_cap_tick()
653 meta_cap_buf->vb.vb2_buf.timestamp = f_time + dev->cap_frame_eof_offset; in vivid_thread_vid_cap_tick()
656 dev->dqbuf_error = false; in vivid_thread_vid_cap_tick()
660 tpg_update_mv_count(&dev->tpg, dev->field_cap == V4L2_FIELD_NONE || in vivid_thread_vid_cap_tick()
661 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_thread_vid_cap_tick()
666 struct vivid_dev *dev = data; in vivid_thread_vid_cap() local
677 dprintk(dev, 1, "Video Capture Thread Start\n"); in vivid_thread_vid_cap()
682 dev->cap_seq_offset = 0; in vivid_thread_vid_cap()
683 dev->cap_seq_count = 0; in vivid_thread_vid_cap()
684 dev->cap_seq_resync = false; in vivid_thread_vid_cap()
685 dev->jiffies_vid_cap = jiffies; in vivid_thread_vid_cap()
686 dev->cap_stream_start = ktime_get_ns(); in vivid_thread_vid_cap()
687 if (dev->time_wrap) in vivid_thread_vid_cap()
688 dev->time_wrap_offset = dev->time_wrap - dev->cap_stream_start; in vivid_thread_vid_cap()
690 dev->time_wrap_offset = 0; in vivid_thread_vid_cap()
691 vivid_cap_update_frame_period(dev); in vivid_thread_vid_cap()
698 if (!mutex_trylock(&dev->mutex)) { in vivid_thread_vid_cap()
704 if (dev->cap_seq_resync) { in vivid_thread_vid_cap()
705 dev->jiffies_vid_cap = cur_jiffies; in vivid_thread_vid_cap()
706 dev->cap_seq_offset = dev->cap_seq_count + 1; in vivid_thread_vid_cap()
707 dev->cap_seq_count = 0; in vivid_thread_vid_cap()
708 dev->cap_stream_start += dev->cap_frame_period * in vivid_thread_vid_cap()
709 dev->cap_seq_offset; in vivid_thread_vid_cap()
710 vivid_cap_update_frame_period(dev); in vivid_thread_vid_cap()
711 dev->cap_seq_resync = false; in vivid_thread_vid_cap()
713 numerator = dev->timeperframe_vid_cap.numerator; in vivid_thread_vid_cap()
714 denominator = dev->timeperframe_vid_cap.denominator; in vivid_thread_vid_cap()
716 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_thread_vid_cap()
720 jiffies_since_start = cur_jiffies - dev->jiffies_vid_cap; in vivid_thread_vid_cap()
733 dev->jiffies_vid_cap = cur_jiffies; in vivid_thread_vid_cap()
734 dev->cap_seq_offset = buffers_since_start; in vivid_thread_vid_cap()
737 dropped_bufs = buffers_since_start + dev->cap_seq_offset - dev->cap_seq_count; in vivid_thread_vid_cap()
738 dev->cap_seq_count = buffers_since_start + dev->cap_seq_offset; in vivid_thread_vid_cap()
739 dev->vid_cap_seq_count = dev->cap_seq_count - dev->vid_cap_seq_start; in vivid_thread_vid_cap()
740 dev->vbi_cap_seq_count = dev->cap_seq_count - dev->vbi_cap_seq_start; in vivid_thread_vid_cap()
741 dev->meta_cap_seq_count = dev->cap_seq_count - dev->meta_cap_seq_start; in vivid_thread_vid_cap()
743 vivid_thread_vid_cap_tick(dev, dropped_bufs); in vivid_thread_vid_cap()
752 jiffies_since_start = jiffies - dev->jiffies_vid_cap; in vivid_thread_vid_cap()
754 mutex_unlock(&dev->mutex); in vivid_thread_vid_cap()
772 dprintk(dev, 1, "Video Capture Thread End\n"); in vivid_thread_vid_cap()
776 static void vivid_grab_controls(struct vivid_dev *dev, bool grab) in vivid_grab_controls() argument
778 v4l2_ctrl_grab(dev->ctrl_has_crop_cap, grab); in vivid_grab_controls()
779 v4l2_ctrl_grab(dev->ctrl_has_compose_cap, grab); in vivid_grab_controls()
780 v4l2_ctrl_grab(dev->ctrl_has_scaler_cap, grab); in vivid_grab_controls()
783 int vivid_start_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming) in vivid_start_generating_vid_cap() argument
785 dprintk(dev, 1, "%s\n", __func__); in vivid_start_generating_vid_cap()
787 if (dev->kthread_vid_cap) { in vivid_start_generating_vid_cap()
788 u32 seq_count = dev->cap_seq_count + dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
790 if (pstreaming == &dev->vid_cap_streaming) in vivid_start_generating_vid_cap()
791 dev->vid_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
792 else if (pstreaming == &dev->vbi_cap_streaming) in vivid_start_generating_vid_cap()
793 dev->vbi_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
795 dev->meta_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
801 tpg_init_mv_count(&dev->tpg); in vivid_start_generating_vid_cap()
803 dev->vid_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
804 dev->vbi_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
805 dev->meta_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
807 dev->kthread_vid_cap = kthread_run(vivid_thread_vid_cap, dev, in vivid_start_generating_vid_cap()
808 "%s-vid-cap", dev->v4l2_dev.name); in vivid_start_generating_vid_cap()
810 if (IS_ERR(dev->kthread_vid_cap)) { in vivid_start_generating_vid_cap()
811 int err = PTR_ERR(dev->kthread_vid_cap); in vivid_start_generating_vid_cap()
813 dev->kthread_vid_cap = NULL; in vivid_start_generating_vid_cap()
814 v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n"); in vivid_start_generating_vid_cap()
818 vivid_grab_controls(dev, true); in vivid_start_generating_vid_cap()
820 dprintk(dev, 1, "returning from %s\n", __func__); in vivid_start_generating_vid_cap()
824 void vivid_stop_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming) in vivid_stop_generating_vid_cap() argument
826 dprintk(dev, 1, "%s\n", __func__); in vivid_stop_generating_vid_cap()
828 if (dev->kthread_vid_cap == NULL) in vivid_stop_generating_vid_cap()
832 if (pstreaming == &dev->vid_cap_streaming) { in vivid_stop_generating_vid_cap()
834 while (!list_empty(&dev->vid_cap_active)) { in vivid_stop_generating_vid_cap()
837 buf = list_entry(dev->vid_cap_active.next, in vivid_stop_generating_vid_cap()
841 &dev->ctrl_hdl_vid_cap); in vivid_stop_generating_vid_cap()
843 dprintk(dev, 2, "vid_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
848 if (pstreaming == &dev->vbi_cap_streaming) { in vivid_stop_generating_vid_cap()
849 while (!list_empty(&dev->vbi_cap_active)) { in vivid_stop_generating_vid_cap()
852 buf = list_entry(dev->vbi_cap_active.next, in vivid_stop_generating_vid_cap()
856 &dev->ctrl_hdl_vbi_cap); in vivid_stop_generating_vid_cap()
858 dprintk(dev, 2, "vbi_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
863 if (pstreaming == &dev->meta_cap_streaming) { in vivid_stop_generating_vid_cap()
864 while (!list_empty(&dev->meta_cap_active)) { in vivid_stop_generating_vid_cap()
867 buf = list_entry(dev->meta_cap_active.next, in vivid_stop_generating_vid_cap()
871 &dev->ctrl_hdl_meta_cap); in vivid_stop_generating_vid_cap()
873 dprintk(dev, 2, "meta_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
878 if (dev->vid_cap_streaming || dev->vbi_cap_streaming || in vivid_stop_generating_vid_cap()
879 dev->meta_cap_streaming) in vivid_stop_generating_vid_cap()
883 vivid_grab_controls(dev, false); in vivid_stop_generating_vid_cap()
884 kthread_stop(dev->kthread_vid_cap); in vivid_stop_generating_vid_cap()
885 dev->kthread_vid_cap = NULL; in vivid_stop_generating_vid_cap()