Lines Matching full: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, struct vivid_dev *out_dev) in vivid_precalc_copy_rects() argument
149 0, 0, dev->display_width, dev->display_height in vivid_precalc_copy_rects()
157 v4l2_rect_intersect(&dev->loop_vid_copy, &dev->crop_cap, &out_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, &out_dev->compose_out, &out_dev->crop_out); in vivid_precalc_copy_rects()
161 dev->loop_vid_out.left += out_dev->crop_out.left; in vivid_precalc_copy_rects()
162 dev->loop_vid_out.top += out_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()
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()
185 /* shift dev->loop_fb_copy back again to the fb origin */ in vivid_precalc_copy_rects()
186 dev->loop_fb_copy.left -= out_dev->compose_out.left - out_dev->overlay_out_left; in vivid_precalc_copy_rects()
187 dev->loop_fb_copy.top -= out_dev->compose_out.top - out_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, in vivid_copy_buffer() argument
220 bool blank = dev->must_blank[vid_cap_buf->vb.vb2_buf.index]; in vivid_copy_buffer()
221 struct tpg_data *tpg = &dev->tpg; in vivid_copy_buffer()
225 unsigned img_width = tpg_hdiv(tpg, p, dev->compose_cap.width); in vivid_copy_buffer()
226 unsigned img_height = dev->compose_cap.height; in vivid_copy_buffer()
229 unsigned stride_osd = dev->display_byte_stride; in vivid_copy_buffer()
244 unsigned vid_cap_left = tpg_hdiv(tpg, p, dev->loop_vid_cap.left); in vivid_copy_buffer()
248 vid_out_int_part = dev->loop_vid_out.height / dev->loop_vid_cap.height; in vivid_copy_buffer()
249 vid_out_fract_part = dev->loop_vid_out.height % dev->loop_vid_cap.height; in vivid_copy_buffer()
263 voutbuf += tpg_hdiv(tpg, p, dev->loop_vid_out.left) + in vivid_copy_buffer()
264 (dev->loop_vid_out.top / vdiv) * stride_out; in vivid_copy_buffer()
265 vcapbuf += tpg_hdiv(tpg, p, dev->compose_cap.left) + in vivid_copy_buffer()
266 (dev->compose_cap.top / vdiv) * stride_cap; in vivid_copy_buffer()
268 if (dev->loop_vid_copy.width == 0 || dev->loop_vid_copy.height == 0) { in vivid_copy_buffer()
279 dev->loop_vid_overlay.width && dev->loop_vid_overlay.height) { in vivid_copy_buffer()
280 vosdbuf = dev->video_vbase; in vivid_copy_buffer()
281 vosdbuf += (dev->loop_fb_copy.left * twopixsize) / 2 + in vivid_copy_buffer()
282 dev->loop_fb_copy.top * stride_osd; in vivid_copy_buffer()
283 vid_overlay_int_part = dev->loop_vid_overlay.height / in vivid_copy_buffer()
284 dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
285 vid_overlay_fract_part = dev->loop_vid_overlay.height % in vivid_copy_buffer()
286 dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
289 vid_cap_right = tpg_hdiv(tpg, p, dev->loop_vid_cap.left + dev->loop_vid_cap.width); in vivid_copy_buffer()
291 quick = dev->loop_vid_out.width == dev->loop_vid_cap.width; in vivid_copy_buffer()
293 dev->cur_scaled_line = dev->loop_vid_out.height; in vivid_copy_buffer()
296 bool osdline = vosdbuf && y >= dev->loop_vid_overlay_cap.top && in vivid_copy_buffer()
297 y < dev->loop_vid_overlay_cap.top + dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
303 if (y < dev->loop_vid_cap.top || in vivid_copy_buffer()
304 y >= dev->loop_vid_cap.top + dev->loop_vid_cap.height) { in vivid_copy_buffer()
310 if (dev->loop_vid_cap.left) in vivid_copy_buffer()
321 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
324 if (dev->cur_scaled_line == vid_out_y) { in vivid_copy_buffer()
325 memcpy(vcapbuf + vid_cap_left, dev->scaled_line, in vivid_copy_buffer()
326 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
330 scale_line(voutbuf + vid_out_y * stride_out, dev->scaled_line, in vivid_copy_buffer()
331 tpg_hdiv(tpg, p, dev->loop_vid_out.width), in vivid_copy_buffer()
332 tpg_hdiv(tpg, p, dev->loop_vid_cap.width), in vivid_copy_buffer()
340 ((dev->loop_vid_overlay.left - dev->loop_vid_copy.left) * in vivid_copy_buffer()
344 scale_line(voutbuf + vid_out_y * stride_out, dev->blended_line, in vivid_copy_buffer()
345 dev->loop_vid_out.width, dev->loop_vid_copy.width, in vivid_copy_buffer()
348 blend_line(dev, vid_overlay_y + dev->loop_vid_overlay.top, in vivid_copy_buffer()
349 dev->loop_vid_overlay.left, in vivid_copy_buffer()
350 dev->blended_line + offset, osd, in vivid_copy_buffer()
351 dev->loop_vid_overlay.width, twopixsize / 2); in vivid_copy_buffer()
353 memcpy(dev->blended_line + offset, in vivid_copy_buffer()
354 osd, (dev->loop_vid_overlay.width * twopixsize) / 2); in vivid_copy_buffer()
355 scale_line(dev->blended_line, dev->scaled_line, in vivid_copy_buffer()
356 dev->loop_vid_copy.width, dev->loop_vid_cap.width, in vivid_copy_buffer()
359 dev->cur_scaled_line = vid_out_y; in vivid_copy_buffer()
360 memcpy(vcapbuf + vid_cap_left, dev->scaled_line, in vivid_copy_buffer()
361 tpg_hdiv(tpg, p, dev->loop_vid_cap.width)); in vivid_copy_buffer()
367 if (vid_overlay_error >= dev->loop_vid_overlay_cap.height) { in vivid_copy_buffer()
368 vid_overlay_error -= dev->loop_vid_overlay_cap.height; in vivid_copy_buffer()
374 if (vid_out_error >= dev->loop_vid_cap.height / vdiv) { in vivid_copy_buffer()
375 vid_out_error -= dev->loop_vid_cap.height / vdiv; in vivid_copy_buffer()
387 static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf) in vivid_fillbuff() argument
390 struct tpg_data *tpg = &dev->tpg; in vivid_fillbuff()
391 unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_cap) ? 2 : 1; in vivid_fillbuff()
393 bool is_tv = vivid_is_sdtv_cap(dev); in vivid_fillbuff()
394 bool is_60hz = is_tv && (dev->std_cap[dev->input] & V4L2_STD_525_60); in vivid_fillbuff()
402 buf->vb.sequence = dev->vid_cap_seq_count; in vivid_fillbuff()
403 v4l2_ctrl_s_ctrl(dev->ro_int32, buf->vb.sequence & 0xff); in vivid_fillbuff()
404 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { in vivid_fillbuff()
411 buf->vb.field = ((dev->vid_cap_seq_count & 1) ^ is_60hz) ? in vivid_fillbuff()
419 buf->vb.field = dev->field_cap; in vivid_fillbuff()
422 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_fillbuff()
423 tpg_s_perc_fill_blank(tpg, dev->must_blank[buf->vb.vb2_buf.index]); in vivid_fillbuff()
425 if (vivid_vid_can_loop(dev) && in vivid_fillbuff()
426 ((vivid_is_svid_cap(dev) && in vivid_fillbuff()
427 !VIVID_INVALID_SIGNAL(dev->std_signal_mode[dev->input])) || in vivid_fillbuff()
428 (vivid_is_hdmi_cap(dev) && in vivid_fillbuff()
429 !VIVID_INVALID_SIGNAL(dev->dv_timings_signal_mode[dev->input])))) { in vivid_fillbuff()
430 out_dev = vivid_input_is_connected_to(dev); in vivid_fillbuff()
447 if (out_dev && dev != out_dev && !mutex_trylock(&out_dev->mutex)) in vivid_fillbuff()
452 vivid_precalc_copy_rects(dev, out_dev); in vivid_fillbuff()
463 if (p < tpg_g_buffers(tpg) && dev->fmt_cap->data_offset[p]) { in vivid_fillbuff()
464 memset(vbuf, dev->fmt_cap->data_offset[p] & 0xff, in vivid_fillbuff()
465 dev->fmt_cap->data_offset[p]); in vivid_fillbuff()
466 vbuf += dev->fmt_cap->data_offset[p]; in vivid_fillbuff()
469 if (!out_dev || vivid_copy_buffer(dev, out_dev, p, vbuf, buf)) in vivid_fillbuff()
470 tpg_fill_plane_buffer(tpg, vivid_get_std_cap(dev), in vivid_fillbuff()
473 if (out_dev && dev != out_dev) in vivid_fillbuff()
476 dev->must_blank[buf->vb.vb2_buf.index] = false; in vivid_fillbuff()
479 if (dev->field_cap != V4L2_FIELD_ALTERNATE || in vivid_fillbuff()
480 (dev->vid_cap_seq_count & 1) == 0) in vivid_fillbuff()
481 dev->ms_vid_cap = in vivid_fillbuff()
482 jiffies_to_msecs(jiffies - dev->jiffies_vid_cap); in vivid_fillbuff()
484 ms = dev->ms_vid_cap; in vivid_fillbuff()
485 if (dev->osd_mode <= 1) { in vivid_fillbuff()
492 (dev->field_cap == V4L2_FIELD_ALTERNATE) ? in vivid_fillbuff()
497 if (dev->osd_mode == 0) { in vivid_fillbuff()
499 dev->src_rect.width, dev->src_rect.height, dev->input); in vivid_fillbuff()
502 gain = v4l2_ctrl_g_ctrl(dev->gain); in vivid_fillbuff()
503 mutex_lock(dev->ctrl_hdl_user_vid.lock); in vivid_fillbuff()
506 dev->brightness->cur.val, in vivid_fillbuff()
507 dev->contrast->cur.val, in vivid_fillbuff()
508 dev->saturation->cur.val, in vivid_fillbuff()
509 dev->hue->cur.val); in vivid_fillbuff()
513 dev->autogain->cur.val, gain, dev->alpha->cur.val); in vivid_fillbuff()
514 mutex_unlock(dev->ctrl_hdl_user_vid.lock); in vivid_fillbuff()
516 mutex_lock(dev->ctrl_hdl_user_aud.lock); in vivid_fillbuff()
519 dev->volume->cur.val, dev->mute->cur.val); in vivid_fillbuff()
520 mutex_unlock(dev->ctrl_hdl_user_aud.lock); in vivid_fillbuff()
522 mutex_lock(dev->ctrl_hdl_user_gen.lock); in vivid_fillbuff()
524 dev->int32->cur.val, in vivid_fillbuff()
525 dev->ro_int32->cur.val, in vivid_fillbuff()
526 *dev->int64->p_cur.p_s64, in vivid_fillbuff()
527 dev->bitmask->cur.val); in vivid_fillbuff()
530 dev->boolean->cur.val, in vivid_fillbuff()
531 dev->menu->qmenu[dev->menu->cur.val], in vivid_fillbuff()
532 dev->string->p_cur.p_char); in vivid_fillbuff()
535 dev->int_menu->qmenu_int[dev->int_menu->cur.val], in vivid_fillbuff()
536 dev->int_menu->cur.val); in vivid_fillbuff()
537 mutex_unlock(dev->ctrl_hdl_user_gen.lock); in vivid_fillbuff()
539 if (dev->button_pressed) { in vivid_fillbuff()
540 dev->button_pressed--; in vivid_fillbuff()
544 if (dev->osd[0]) { in vivid_fillbuff()
545 if (vivid_is_hdmi_cap(dev)) { in vivid_fillbuff()
547 " OSD \"%s\"", dev->osd); in vivid_fillbuff()
551 if (dev->osd_jiffies && in vivid_fillbuff()
552 time_is_before_jiffies(dev->osd_jiffies + 5 * HZ)) { in vivid_fillbuff()
553 dev->osd[0] = 0; in vivid_fillbuff()
554 dev->osd_jiffies = 0; in vivid_fillbuff()
560 static void vivid_cap_update_frame_period(struct vivid_dev *dev) in vivid_cap_update_frame_period() argument
564 f_period = (u64)dev->timeperframe_vid_cap.numerator * 1000000000; in vivid_cap_update_frame_period()
565 if (WARN_ON(dev->timeperframe_vid_cap.denominator == 0)) in vivid_cap_update_frame_period()
566 dev->timeperframe_vid_cap.denominator = 1; in vivid_cap_update_frame_period()
567 do_div(f_period, dev->timeperframe_vid_cap.denominator); in vivid_cap_update_frame_period()
568 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_cap_update_frame_period()
574 dev->cap_frame_eof_offset = f_period * 9; in vivid_cap_update_frame_period()
575 do_div(dev->cap_frame_eof_offset, 10); in vivid_cap_update_frame_period()
576 dev->cap_frame_period = f_period; in vivid_cap_update_frame_period()
579 static noinline_for_stack void vivid_thread_vid_cap_tick(struct vivid_dev *dev, in vivid_thread_vid_cap_tick() argument
587 dprintk(dev, 1, "Video Capture Thread Tick\n"); in vivid_thread_vid_cap_tick()
590 tpg_update_mv_count(&dev->tpg, in vivid_thread_vid_cap_tick()
591 dev->field_cap == V4L2_FIELD_NONE || in vivid_thread_vid_cap_tick()
592 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_thread_vid_cap_tick()
595 if (dev->perc_dropped_buffers && in vivid_thread_vid_cap_tick()
596 get_random_u32_below(100) < dev->perc_dropped_buffers) in vivid_thread_vid_cap_tick()
599 spin_lock(&dev->slock); in vivid_thread_vid_cap_tick()
600 if (!list_empty(&dev->vid_cap_active)) { in vivid_thread_vid_cap_tick()
601 vid_cap_buf = list_entry(dev->vid_cap_active.next, struct vivid_buffer, list); in vivid_thread_vid_cap_tick()
604 if (!list_empty(&dev->vbi_cap_active)) { in vivid_thread_vid_cap_tick()
605 if (dev->field_cap != V4L2_FIELD_ALTERNATE || in vivid_thread_vid_cap_tick()
606 (dev->vbi_cap_seq_count & 1)) { in vivid_thread_vid_cap_tick()
607 vbi_cap_buf = list_entry(dev->vbi_cap_active.next, in vivid_thread_vid_cap_tick()
612 if (!list_empty(&dev->meta_cap_active)) { in vivid_thread_vid_cap_tick()
613 meta_cap_buf = list_entry(dev->meta_cap_active.next, in vivid_thread_vid_cap_tick()
618 spin_unlock(&dev->slock); in vivid_thread_vid_cap_tick()
623 f_time = ktime_get_ns() + dev->time_wrap_offset; in vivid_thread_vid_cap_tick()
627 &dev->ctrl_hdl_vid_cap); in vivid_thread_vid_cap_tick()
629 vivid_fillbuff(dev, vid_cap_buf); in vivid_thread_vid_cap_tick()
630 dprintk(dev, 1, "filled buffer %d\n", in vivid_thread_vid_cap_tick()
634 &dev->ctrl_hdl_vid_cap); in vivid_thread_vid_cap_tick()
635 vb2_buffer_done(&vid_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
637 dprintk(dev, 2, "vid_cap buffer %d done\n", in vivid_thread_vid_cap_tick()
641 if (!dev->tstamp_src_is_soe) in vivid_thread_vid_cap_tick()
642 vid_cap_buf->vb.vb2_buf.timestamp += dev->cap_frame_eof_offset; in vivid_thread_vid_cap_tick()
649 &dev->ctrl_hdl_vbi_cap); in vivid_thread_vid_cap_tick()
651 vivid_sliced_vbi_cap_process(dev, vbi_cap_buf); in vivid_thread_vid_cap_tick()
653 vivid_raw_vbi_cap_process(dev, vbi_cap_buf); in vivid_thread_vid_cap_tick()
655 &dev->ctrl_hdl_vbi_cap); in vivid_thread_vid_cap_tick()
656 vb2_buffer_done(&vbi_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
658 dprintk(dev, 2, "vbi_cap %d done\n", in vivid_thread_vid_cap_tick()
662 vbi_period = dev->cap_frame_period * 5; in vivid_thread_vid_cap_tick()
664 vbi_cap_buf->vb.vb2_buf.timestamp = f_time + dev->cap_frame_eof_offset + vbi_period; in vivid_thread_vid_cap_tick()
669 &dev->ctrl_hdl_meta_cap); in vivid_thread_vid_cap_tick()
670 vivid_meta_cap_fillbuff(dev, meta_cap_buf, f_time); in vivid_thread_vid_cap_tick()
672 &dev->ctrl_hdl_meta_cap); in vivid_thread_vid_cap_tick()
673 vb2_buffer_done(&meta_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_vid_cap_tick()
675 dprintk(dev, 2, "meta_cap %d done\n", in vivid_thread_vid_cap_tick()
677 meta_cap_buf->vb.vb2_buf.timestamp = f_time + dev->cap_frame_eof_offset; in vivid_thread_vid_cap_tick()
680 dev->dqbuf_error = false; in vivid_thread_vid_cap_tick()
684 tpg_update_mv_count(&dev->tpg, dev->field_cap == V4L2_FIELD_NONE || in vivid_thread_vid_cap_tick()
685 dev->field_cap == V4L2_FIELD_ALTERNATE); in vivid_thread_vid_cap_tick()
690 struct vivid_dev *dev = data; in vivid_thread_vid_cap() local
701 dprintk(dev, 1, "Video Capture Thread Start\n"); in vivid_thread_vid_cap()
706 dev->cap_seq_offset = 0; in vivid_thread_vid_cap()
707 dev->cap_seq_count = 0; in vivid_thread_vid_cap()
708 dev->cap_seq_resync = false; in vivid_thread_vid_cap()
709 dev->jiffies_vid_cap = jiffies; in vivid_thread_vid_cap()
710 dev->cap_stream_start = ktime_get_ns(); in vivid_thread_vid_cap()
711 if (dev->time_wrap) in vivid_thread_vid_cap()
712 dev->time_wrap_offset = dev->time_wrap - dev->cap_stream_start; in vivid_thread_vid_cap()
714 dev->time_wrap_offset = 0; in vivid_thread_vid_cap()
715 vivid_cap_update_frame_period(dev); in vivid_thread_vid_cap()
722 if (!mutex_trylock(&dev->mutex)) { in vivid_thread_vid_cap()
728 if (dev->cap_seq_resync) { in vivid_thread_vid_cap()
729 dev->jiffies_vid_cap = cur_jiffies; in vivid_thread_vid_cap()
730 dev->cap_seq_offset = dev->cap_seq_count + 1; in vivid_thread_vid_cap()
731 dev->cap_seq_count = 0; in vivid_thread_vid_cap()
732 dev->cap_stream_start += dev->cap_frame_period * in vivid_thread_vid_cap()
733 dev->cap_seq_offset; in vivid_thread_vid_cap()
734 vivid_cap_update_frame_period(dev); in vivid_thread_vid_cap()
735 dev->cap_seq_resync = false; in vivid_thread_vid_cap()
737 numerator = dev->timeperframe_vid_cap.numerator; in vivid_thread_vid_cap()
738 denominator = dev->timeperframe_vid_cap.denominator; in vivid_thread_vid_cap()
740 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_thread_vid_cap()
744 jiffies_since_start = cur_jiffies - dev->jiffies_vid_cap; in vivid_thread_vid_cap()
757 dev->jiffies_vid_cap = cur_jiffies; in vivid_thread_vid_cap()
758 dev->cap_seq_offset = buffers_since_start; in vivid_thread_vid_cap()
761 dropped_bufs = buffers_since_start + dev->cap_seq_offset - dev->cap_seq_count; in vivid_thread_vid_cap()
762 dev->cap_seq_count = buffers_since_start + dev->cap_seq_offset; in vivid_thread_vid_cap()
763 dev->vid_cap_seq_count = dev->cap_seq_count - dev->vid_cap_seq_start; in vivid_thread_vid_cap()
764 dev->vbi_cap_seq_count = dev->cap_seq_count - dev->vbi_cap_seq_start; in vivid_thread_vid_cap()
765 dev->meta_cap_seq_count = dev->cap_seq_count - dev->meta_cap_seq_start; in vivid_thread_vid_cap()
767 vivid_thread_vid_cap_tick(dev, dropped_bufs); in vivid_thread_vid_cap()
776 jiffies_since_start = jiffies - dev->jiffies_vid_cap; in vivid_thread_vid_cap()
778 mutex_unlock(&dev->mutex); in vivid_thread_vid_cap()
796 dprintk(dev, 1, "Video Capture Thread End\n"); in vivid_thread_vid_cap()
800 static void vivid_grab_controls(struct vivid_dev *dev, bool grab) in vivid_grab_controls() argument
802 v4l2_ctrl_grab(dev->ctrl_has_crop_cap, grab); in vivid_grab_controls()
803 v4l2_ctrl_grab(dev->ctrl_has_compose_cap, grab); in vivid_grab_controls()
804 v4l2_ctrl_grab(dev->ctrl_has_scaler_cap, grab); in vivid_grab_controls()
807 int vivid_start_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming) in vivid_start_generating_vid_cap() argument
809 dprintk(dev, 1, "%s\n", __func__); in vivid_start_generating_vid_cap()
811 if (dev->kthread_vid_cap) { in vivid_start_generating_vid_cap()
812 u32 seq_count = dev->cap_seq_count + dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
814 if (pstreaming == &dev->vid_cap_streaming) in vivid_start_generating_vid_cap()
815 dev->vid_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
816 else if (pstreaming == &dev->vbi_cap_streaming) in vivid_start_generating_vid_cap()
817 dev->vbi_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
819 dev->meta_cap_seq_start = seq_count; in vivid_start_generating_vid_cap()
825 tpg_init_mv_count(&dev->tpg); in vivid_start_generating_vid_cap()
827 dev->vid_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
828 dev->vbi_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
829 dev->meta_cap_seq_start = dev->seq_wrap * 128; in vivid_start_generating_vid_cap()
831 dev->kthread_vid_cap = kthread_run(vivid_thread_vid_cap, dev, in vivid_start_generating_vid_cap()
832 "%s-vid-cap", dev->v4l2_dev.name); in vivid_start_generating_vid_cap()
834 if (IS_ERR(dev->kthread_vid_cap)) { in vivid_start_generating_vid_cap()
835 int err = PTR_ERR(dev->kthread_vid_cap); in vivid_start_generating_vid_cap()
837 dev->kthread_vid_cap = NULL; in vivid_start_generating_vid_cap()
838 v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n"); in vivid_start_generating_vid_cap()
842 vivid_grab_controls(dev, true); in vivid_start_generating_vid_cap()
844 dprintk(dev, 1, "returning from %s\n", __func__); in vivid_start_generating_vid_cap()
848 void vivid_stop_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming) in vivid_stop_generating_vid_cap() argument
850 dprintk(dev, 1, "%s\n", __func__); in vivid_stop_generating_vid_cap()
852 if (dev->kthread_vid_cap == NULL) in vivid_stop_generating_vid_cap()
856 if (pstreaming == &dev->vid_cap_streaming) { in vivid_stop_generating_vid_cap()
858 while (!list_empty(&dev->vid_cap_active)) { in vivid_stop_generating_vid_cap()
861 buf = list_entry(dev->vid_cap_active.next, in vivid_stop_generating_vid_cap()
865 &dev->ctrl_hdl_vid_cap); in vivid_stop_generating_vid_cap()
867 dprintk(dev, 2, "vid_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
872 if (pstreaming == &dev->vbi_cap_streaming) { in vivid_stop_generating_vid_cap()
873 while (!list_empty(&dev->vbi_cap_active)) { in vivid_stop_generating_vid_cap()
876 buf = list_entry(dev->vbi_cap_active.next, in vivid_stop_generating_vid_cap()
880 &dev->ctrl_hdl_vbi_cap); in vivid_stop_generating_vid_cap()
882 dprintk(dev, 2, "vbi_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
887 if (pstreaming == &dev->meta_cap_streaming) { in vivid_stop_generating_vid_cap()
888 while (!list_empty(&dev->meta_cap_active)) { in vivid_stop_generating_vid_cap()
891 buf = list_entry(dev->meta_cap_active.next, in vivid_stop_generating_vid_cap()
895 &dev->ctrl_hdl_meta_cap); in vivid_stop_generating_vid_cap()
897 dprintk(dev, 2, "meta_cap buffer %d done\n", in vivid_stop_generating_vid_cap()
902 if (dev->vid_cap_streaming || dev->vbi_cap_streaming || in vivid_stop_generating_vid_cap()
903 dev->meta_cap_streaming) in vivid_stop_generating_vid_cap()
907 vivid_grab_controls(dev, false); in vivid_stop_generating_vid_cap()
908 kthread_stop(dev->kthread_vid_cap); in vivid_stop_generating_vid_cap()
909 dev->kthread_vid_cap = NULL; in vivid_stop_generating_vid_cap()