Lines Matching full:dev

59 static inline unsigned int webcam_ival_count(const struct vivid_dev *dev,  in webcam_ival_count()  argument
79 struct vivid_dev *dev = vb2_get_drv_priv(vq); in vid_cap_queue_setup() local
80 unsigned buffers = tpg_g_buffers(&dev->tpg); in vid_cap_queue_setup()
81 unsigned h = dev->fmt_cap_rect.height; in vid_cap_queue_setup()
84 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { in vid_cap_queue_setup()
93 if (dev->queue_setup_error) { in vid_cap_queue_setup()
98 dev->queue_setup_error = false; in vid_cap_queue_setup()
109 if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h / in vid_cap_queue_setup()
110 dev->fmt_cap->vdownsampling[p] + in vid_cap_queue_setup()
111 dev->fmt_cap->data_offset[p]) in vid_cap_queue_setup()
116 sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / in vid_cap_queue_setup()
117 dev->fmt_cap->vdownsampling[p] + in vid_cap_queue_setup()
118 dev->fmt_cap->data_offset[p]; in vid_cap_queue_setup()
123 dprintk(dev, 1, "%s: count=%d\n", __func__, *nbuffers); in vid_cap_queue_setup()
125 dprintk(dev, 1, "%s: size[%u]=%u\n", __func__, p, sizes[p]); in vid_cap_queue_setup()
132 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_prepare() local
134 unsigned buffers = tpg_g_buffers(&dev->tpg); in vid_cap_buf_prepare()
137 dprintk(dev, 1, "%s\n", __func__); in vid_cap_buf_prepare()
139 if (WARN_ON(NULL == dev->fmt_cap)) in vid_cap_buf_prepare()
142 if (dev->buf_prepare_error) { in vid_cap_buf_prepare()
147 dev->buf_prepare_error = false; in vid_cap_buf_prepare()
151 size = (tpg_g_line_width(&dev->tpg, p) * in vid_cap_buf_prepare()
152 dev->fmt_cap_rect.height) / in vid_cap_buf_prepare()
153 dev->fmt_cap->vdownsampling[p] + in vid_cap_buf_prepare()
154 dev->fmt_cap->data_offset[p]; in vid_cap_buf_prepare()
157 dprintk(dev, 1, "%s data will not fit into plane %u (%lu < %lu)\n", in vid_cap_buf_prepare()
163 vb->planes[p].data_offset = dev->fmt_cap->data_offset[p]; in vid_cap_buf_prepare()
172 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_finish() local
177 if (!vivid_is_sdtv_cap(dev)) in vid_cap_buf_finish()
185 if (dev->std_cap[dev->input] & V4L2_STD_525_60) in vid_cap_buf_finish()
198 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_queue() local
201 dprintk(dev, 1, "%s\n", __func__); in vid_cap_buf_queue()
203 spin_lock(&dev->slock); in vid_cap_buf_queue()
204 list_add_tail(&buf->list, &dev->vid_cap_active); in vid_cap_buf_queue()
205 spin_unlock(&dev->slock); in vid_cap_buf_queue()
210 struct vivid_dev *dev = vb2_get_drv_priv(vq); in vid_cap_start_streaming() local
214 dev->vid_cap_seq_count = 0; in vid_cap_start_streaming()
215 dprintk(dev, 1, "%s\n", __func__); in vid_cap_start_streaming()
217 dev->must_blank[i] = tpg_g_perc_fill(&dev->tpg) < 100; in vid_cap_start_streaming()
218 if (dev->start_streaming_error) { in vid_cap_start_streaming()
219 dev->start_streaming_error = false; in vid_cap_start_streaming()
222 err = vivid_start_generating_vid_cap(dev, &dev->vid_cap_streaming); in vid_cap_start_streaming()
227 list_for_each_entry_safe(buf, tmp, &dev->vid_cap_active, list) { in vid_cap_start_streaming()
239 struct vivid_dev *dev = vb2_get_drv_priv(vq); in vid_cap_stop_streaming() local
241 dprintk(dev, 1, "%s\n", __func__); in vid_cap_stop_streaming()
242 vivid_stop_generating_vid_cap(dev, &dev->vid_cap_streaming); in vid_cap_stop_streaming()
247 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_request_complete() local
249 v4l2_ctrl_request_complete(vb->req_obj.req, &dev->ctrl_hdl_vid_cap); in vid_cap_buf_request_complete()
269 void vivid_update_quality(struct vivid_dev *dev) in vivid_update_quality() argument
273 if (dev->input_is_connected_to_output[dev->input]) { in vivid_update_quality()
278 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
281 if (vivid_is_hdmi_cap(dev) && in vivid_update_quality()
282 VIVID_INVALID_SIGNAL(dev->dv_timings_signal_mode[dev->input])) { in vivid_update_quality()
283 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
286 if (vivid_is_sdtv_cap(dev) && in vivid_update_quality()
287 VIVID_INVALID_SIGNAL(dev->std_signal_mode[dev->input])) { in vivid_update_quality()
288 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
291 if (!vivid_is_tv_cap(dev)) { in vivid_update_quality()
292 tpg_s_quality(&dev->tpg, TPG_QUAL_COLOR, 0); in vivid_update_quality()
302 freq_modulus = (dev->tv_freq - 676 /* (43.25-1) * 16 */) % (6 * 16); in vivid_update_quality()
304 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, in vivid_update_quality()
305 next_pseudo_random32(dev->tv_freq ^ 0x55) & 0x3f); in vivid_update_quality()
309 tpg_s_quality(&dev->tpg, TPG_QUAL_GRAY, 0); in vivid_update_quality()
311 tpg_s_quality(&dev->tpg, TPG_QUAL_COLOR, 0); in vivid_update_quality()
317 static enum tpg_quality vivid_get_quality(struct vivid_dev *dev, s32 *afc) in vivid_get_quality() argument
323 if (tpg_g_quality(&dev->tpg) == TPG_QUAL_COLOR || in vivid_get_quality()
324 tpg_g_quality(&dev->tpg) == TPG_QUAL_NOISE) in vivid_get_quality()
325 return tpg_g_quality(&dev->tpg); in vivid_get_quality()
333 freq_modulus = (dev->tv_freq - 676 /* (43.25-1) * 16 */) % (6 * 16); in vivid_get_quality()
339 enum tpg_video_aspect vivid_get_video_aspect(const struct vivid_dev *dev) in vivid_get_video_aspect() argument
341 if (vivid_is_sdtv_cap(dev)) in vivid_get_video_aspect()
342 return dev->std_aspect_ratio[dev->input]; in vivid_get_video_aspect()
344 if (vivid_is_hdmi_cap(dev)) in vivid_get_video_aspect()
345 return dev->dv_timings_aspect_ratio[dev->input]; in vivid_get_video_aspect()
350 static enum tpg_pixel_aspect vivid_get_pixel_aspect(const struct vivid_dev *dev) in vivid_get_pixel_aspect() argument
352 if (vivid_is_sdtv_cap(dev)) in vivid_get_pixel_aspect()
353 return (dev->std_cap[dev->input] & V4L2_STD_525_60) ? in vivid_get_pixel_aspect()
356 if (vivid_is_hdmi_cap(dev) && in vivid_get_pixel_aspect()
357 dev->src_rect.width == 720 && dev->src_rect.height <= 576) in vivid_get_pixel_aspect()
358 return dev->src_rect.height == 480 ? in vivid_get_pixel_aspect()
368 void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls) in vivid_update_format_cap() argument
370 struct v4l2_bt_timings *bt = &dev->dv_timings_cap[dev->input].bt; in vivid_update_format_cap()
375 switch (dev->input_type[dev->input]) { in vivid_update_format_cap()
378 dev->src_rect.width = webcam_sizes[dev->webcam_size_idx].width; in vivid_update_format_cap()
379 dev->src_rect.height = webcam_sizes[dev->webcam_size_idx].height; in vivid_update_format_cap()
380 dev->timeperframe_vid_cap = webcam_intervals[dev->webcam_ival_idx]; in vivid_update_format_cap()
381 dev->field_cap = V4L2_FIELD_NONE; in vivid_update_format_cap()
382 tpg_s_rgb_range(&dev->tpg, V4L2_DV_RGB_RANGE_AUTO); in vivid_update_format_cap()
386 dev->field_cap = dev->tv_field_cap; in vivid_update_format_cap()
387 dev->src_rect.width = 720; in vivid_update_format_cap()
388 if (dev->std_cap[dev->input] & V4L2_STD_525_60) { in vivid_update_format_cap()
389 dev->src_rect.height = 480; in vivid_update_format_cap()
390 dev->timeperframe_vid_cap = (struct v4l2_fract) { 1001, 30000 }; in vivid_update_format_cap()
391 dev->service_set_cap = V4L2_SLICED_CAPTION_525; in vivid_update_format_cap()
393 dev->src_rect.height = 576; in vivid_update_format_cap()
394 dev->timeperframe_vid_cap = (struct v4l2_fract) { 1000, 25000 }; in vivid_update_format_cap()
395 dev->service_set_cap = V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B; in vivid_update_format_cap()
397 tpg_s_rgb_range(&dev->tpg, V4L2_DV_RGB_RANGE_AUTO); in vivid_update_format_cap()
400 dev->src_rect.width = bt->width; in vivid_update_format_cap()
401 dev->src_rect.height = bt->height; in vivid_update_format_cap()
403 if (dev->reduced_fps && can_reduce_fps(bt)) { in vivid_update_format_cap()
410 dev->timeperframe_vid_cap = (struct v4l2_fract) { in vivid_update_format_cap()
414 dev->field_cap = V4L2_FIELD_ALTERNATE; in vivid_update_format_cap()
416 dev->field_cap = V4L2_FIELD_NONE; in vivid_update_format_cap()
422 if (keep_controls || !dev->colorspace) in vivid_update_format_cap()
426 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vivid_update_format_cap()
428 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); in vivid_update_format_cap()
429 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1); in vivid_update_format_cap()
431 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vivid_update_format_cap()
432 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0); in vivid_update_format_cap()
434 tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap)); in vivid_update_format_cap()
437 vivid_update_quality(dev); in vivid_update_format_cap()
438 tpg_reset_source(&dev->tpg, dev->src_rect.width, dev->src_rect.height, dev->field_cap); in vivid_update_format_cap()
439 dev->crop_cap = dev->src_rect; in vivid_update_format_cap()
440 dev->crop_bounds_cap = dev->src_rect; in vivid_update_format_cap()
441 dev->compose_cap = dev->crop_cap; in vivid_update_format_cap()
442 if (V4L2_FIELD_HAS_T_OR_B(dev->field_cap)) in vivid_update_format_cap()
443 dev->compose_cap.height /= 2; in vivid_update_format_cap()
444 dev->fmt_cap_rect = dev->compose_cap; in vivid_update_format_cap()
445 tpg_s_video_aspect(&dev->tpg, vivid_get_video_aspect(dev)); in vivid_update_format_cap()
446 tpg_s_pixel_aspect(&dev->tpg, vivid_get_pixel_aspect(dev)); in vivid_update_format_cap()
447 tpg_update_mv_step(&dev->tpg); in vivid_update_format_cap()
456 dims[0] = roundup(dev->src_rect.width, PIXEL_ARRAY_DIV); in vivid_update_format_cap()
457 dims[1] = roundup(dev->src_rect.height, PIXEL_ARRAY_DIV); in vivid_update_format_cap()
458 v4l2_ctrl_modify_dimensions(dev->pixel_array, dims); in vivid_update_format_cap()
462 static enum v4l2_field vivid_field_cap(struct vivid_dev *dev, enum v4l2_field field) in vivid_field_cap() argument
464 if (vivid_is_sdtv_cap(dev)) { in vivid_field_cap()
479 if (vivid_is_hdmi_cap(dev)) in vivid_field_cap()
480 return dev->dv_timings_cap[dev->input].bt.interlaced ? in vivid_field_cap()
485 static unsigned vivid_colorspace_cap(struct vivid_dev *dev) in vivid_colorspace_cap() argument
487 if (!vivid_input_is_connected_to(dev)) in vivid_colorspace_cap()
488 return tpg_g_colorspace(&dev->tpg); in vivid_colorspace_cap()
489 return dev->colorspace_out; in vivid_colorspace_cap()
492 static unsigned vivid_xfer_func_cap(struct vivid_dev *dev) in vivid_xfer_func_cap() argument
494 if (!vivid_input_is_connected_to(dev)) in vivid_xfer_func_cap()
495 return tpg_g_xfer_func(&dev->tpg); in vivid_xfer_func_cap()
496 return dev->xfer_func_out; in vivid_xfer_func_cap()
499 static unsigned vivid_ycbcr_enc_cap(struct vivid_dev *dev) in vivid_ycbcr_enc_cap() argument
501 if (!vivid_input_is_connected_to(dev)) in vivid_ycbcr_enc_cap()
502 return tpg_g_ycbcr_enc(&dev->tpg); in vivid_ycbcr_enc_cap()
503 return dev->ycbcr_enc_out; in vivid_ycbcr_enc_cap()
506 static unsigned int vivid_hsv_enc_cap(struct vivid_dev *dev) in vivid_hsv_enc_cap() argument
508 if (!vivid_input_is_connected_to(dev)) in vivid_hsv_enc_cap()
509 return tpg_g_hsv_enc(&dev->tpg); in vivid_hsv_enc_cap()
510 return dev->hsv_enc_out; in vivid_hsv_enc_cap()
513 static unsigned vivid_quantization_cap(struct vivid_dev *dev) in vivid_quantization_cap() argument
515 if (!vivid_input_is_connected_to(dev)) in vivid_quantization_cap()
516 return tpg_g_quantization(&dev->tpg); in vivid_quantization_cap()
517 return dev->quantization_out; in vivid_quantization_cap()
523 struct vivid_dev *dev = video_drvdata(file); in vivid_g_fmt_vid_cap() local
527 mp->width = dev->fmt_cap_rect.width; in vivid_g_fmt_vid_cap()
528 mp->height = dev->fmt_cap_rect.height; in vivid_g_fmt_vid_cap()
529 mp->field = dev->field_cap; in vivid_g_fmt_vid_cap()
530 mp->pixelformat = dev->fmt_cap->fourcc; in vivid_g_fmt_vid_cap()
531 mp->colorspace = vivid_colorspace_cap(dev); in vivid_g_fmt_vid_cap()
532 mp->xfer_func = vivid_xfer_func_cap(dev); in vivid_g_fmt_vid_cap()
533 if (dev->fmt_cap->color_enc == TGP_COLOR_ENC_HSV) in vivid_g_fmt_vid_cap()
534 mp->hsv_enc = vivid_hsv_enc_cap(dev); in vivid_g_fmt_vid_cap()
536 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_g_fmt_vid_cap()
537 mp->quantization = vivid_quantization_cap(dev); in vivid_g_fmt_vid_cap()
538 mp->num_planes = dev->fmt_cap->buffers; in vivid_g_fmt_vid_cap()
540 mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p); in vivid_g_fmt_vid_cap()
542 (tpg_g_line_width(&dev->tpg, p) * mp->height) / in vivid_g_fmt_vid_cap()
543 dev->fmt_cap->vdownsampling[p] + in vivid_g_fmt_vid_cap()
544 dev->fmt_cap->data_offset[p]; in vivid_g_fmt_vid_cap()
554 struct vivid_dev *dev = video_drvdata(file); in vivid_try_fmt_vid_cap() local
562 fmt = vivid_get_format(dev, mp->pixelformat); in vivid_try_fmt_vid_cap()
564 dprintk(dev, 1, "Fourcc format (0x%08x) unknown.\n", in vivid_try_fmt_vid_cap()
567 fmt = vivid_get_format(dev, mp->pixelformat); in vivid_try_fmt_vid_cap()
570 mp->field = vivid_field_cap(dev, mp->field); in vivid_try_fmt_vid_cap()
571 if (vivid_is_webcam(dev)) { in vivid_try_fmt_vid_cap()
579 } else if (vivid_is_sdtv_cap(dev)) { in vivid_try_fmt_vid_cap()
581 h = (dev->std_cap[dev->input] & V4L2_STD_525_60) ? 480 : 576; in vivid_try_fmt_vid_cap()
583 w = dev->src_rect.width; in vivid_try_fmt_vid_cap()
584 h = dev->src_rect.height; in vivid_try_fmt_vid_cap()
588 if (vivid_is_webcam(dev) || in vivid_try_fmt_vid_cap()
589 (!dev->has_scaler_cap && !dev->has_crop_cap && !dev->has_compose_cap)) { in vivid_try_fmt_vid_cap()
597 if (dev->has_scaler_cap && !dev->has_compose_cap) { in vivid_try_fmt_vid_cap()
601 } else if (!dev->has_scaler_cap && dev->has_crop_cap && !dev->has_compose_cap) { in vivid_try_fmt_vid_cap()
602 v4l2_rect_set_max_size(&r, &dev->src_rect); in vivid_try_fmt_vid_cap()
603 } else if (!dev->has_scaler_cap && !dev->has_crop_cap) { in vivid_try_fmt_vid_cap()
604 v4l2_rect_set_min_size(&r, &dev->src_rect); in vivid_try_fmt_vid_cap()
635 mp->colorspace = vivid_colorspace_cap(dev); in vivid_try_fmt_vid_cap()
638 mp->xfer_func = vivid_xfer_func_cap(dev); in vivid_try_fmt_vid_cap()
642 mp->hsv_enc = vivid_hsv_enc_cap(dev); in vivid_try_fmt_vid_cap()
645 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_try_fmt_vid_cap()
647 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_try_fmt_vid_cap()
653 mp->quantization = vivid_quantization_cap(dev); in vivid_try_fmt_vid_cap()
655 mp->quantization = vivid_quantization_cap(dev); in vivid_try_fmt_vid_cap()
666 struct vivid_dev *dev = video_drvdata(file); in vivid_s_fmt_vid_cap() local
667 struct v4l2_rect *crop = &dev->crop_cap; in vivid_s_fmt_vid_cap()
668 struct v4l2_rect *compose = &dev->compose_cap; in vivid_s_fmt_vid_cap()
669 struct vb2_queue *q = &dev->vb_vid_cap_q; in vivid_s_fmt_vid_cap()
679 dprintk(dev, 1, "%s device busy\n", __func__); in vivid_s_fmt_vid_cap()
683 dev->fmt_cap = vivid_get_format(dev, mp->pixelformat); in vivid_s_fmt_vid_cap()
689 if (!vivid_is_webcam(dev) && in vivid_s_fmt_vid_cap()
690 (dev->has_scaler_cap || dev->has_crop_cap || dev->has_compose_cap)) { in vivid_s_fmt_vid_cap()
693 if (dev->has_scaler_cap) { in vivid_s_fmt_vid_cap()
694 if (dev->has_compose_cap) in vivid_s_fmt_vid_cap()
698 if (dev->has_crop_cap && !dev->has_compose_cap) { in vivid_s_fmt_vid_cap()
712 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
713 } else if (dev->has_crop_cap) { in vivid_s_fmt_vid_cap()
727 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
729 } else if (dev->has_crop_cap && !dev->has_compose_cap) { in vivid_s_fmt_vid_cap()
732 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
736 } else if (!dev->has_crop_cap) { in vivid_s_fmt_vid_cap()
741 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
749 } else if (vivid_is_webcam(dev)) { in vivid_s_fmt_vid_cap()
750 unsigned int ival_sz = webcam_ival_count(dev, dev->webcam_size_idx); in vivid_s_fmt_vid_cap()
757 dev->webcam_size_idx = i; in vivid_s_fmt_vid_cap()
758 if (dev->webcam_ival_idx >= ival_sz) in vivid_s_fmt_vid_cap()
759 dev->webcam_ival_idx = ival_sz - 1; in vivid_s_fmt_vid_cap()
760 vivid_update_format_cap(dev, false); in vivid_s_fmt_vid_cap()
769 dev->fmt_cap_rect.width = mp->width; in vivid_s_fmt_vid_cap()
770 dev->fmt_cap_rect.height = mp->height; in vivid_s_fmt_vid_cap()
771 tpg_s_buf_height(&dev->tpg, mp->height); in vivid_s_fmt_vid_cap()
772 tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc); in vivid_s_fmt_vid_cap()
773 for (p = 0; p < tpg_g_buffers(&dev->tpg); p++) in vivid_s_fmt_vid_cap()
774 tpg_s_bytesperline(&dev->tpg, p, mp->plane_fmt[p].bytesperline); in vivid_s_fmt_vid_cap()
775 dev->field_cap = mp->field; in vivid_s_fmt_vid_cap()
776 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_s_fmt_vid_cap()
777 tpg_s_field(&dev->tpg, V4L2_FIELD_TOP, true); in vivid_s_fmt_vid_cap()
779 tpg_s_field(&dev->tpg, dev->field_cap, false); in vivid_s_fmt_vid_cap()
780 tpg_s_crop_compose(&dev->tpg, &dev->crop_cap, &dev->compose_cap); in vivid_s_fmt_vid_cap()
781 if (vivid_is_sdtv_cap(dev)) in vivid_s_fmt_vid_cap()
782 dev->tv_field_cap = mp->field; in vivid_s_fmt_vid_cap()
783 tpg_update_mv_step(&dev->tpg); in vivid_s_fmt_vid_cap()
784 dev->tpg.colorspace = mp->colorspace; in vivid_s_fmt_vid_cap()
785 dev->tpg.xfer_func = mp->xfer_func; in vivid_s_fmt_vid_cap()
786 if (dev->fmt_cap->color_enc == TGP_COLOR_ENC_YCBCR) in vivid_s_fmt_vid_cap()
787 dev->tpg.ycbcr_enc = mp->ycbcr_enc; in vivid_s_fmt_vid_cap()
789 dev->tpg.hsv_enc = mp->hsv_enc; in vivid_s_fmt_vid_cap()
790 dev->tpg.quantization = mp->quantization; in vivid_s_fmt_vid_cap()
798 struct vivid_dev *dev = video_drvdata(file); in vidioc_g_fmt_vid_cap_mplane() local
800 if (!dev->multiplanar) in vidioc_g_fmt_vid_cap_mplane()
808 struct vivid_dev *dev = video_drvdata(file); in vidioc_try_fmt_vid_cap_mplane() local
810 if (!dev->multiplanar) in vidioc_try_fmt_vid_cap_mplane()
818 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_fmt_vid_cap_mplane() local
820 if (!dev->multiplanar) in vidioc_s_fmt_vid_cap_mplane()
828 struct vivid_dev *dev = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
830 if (dev->multiplanar) in vidioc_g_fmt_vid_cap()
838 struct vivid_dev *dev = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
840 if (dev->multiplanar) in vidioc_try_fmt_vid_cap()
848 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
850 if (dev->multiplanar) in vidioc_s_fmt_vid_cap()
858 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_g_selection() local
860 if (!dev->has_crop_cap && !dev->has_compose_cap) in vivid_vid_cap_g_selection()
864 if (vivid_is_webcam(dev)) in vivid_vid_cap_g_selection()
870 if (!dev->has_crop_cap) in vivid_vid_cap_g_selection()
872 sel->r = dev->crop_cap; in vivid_vid_cap_g_selection()
876 if (!dev->has_crop_cap) in vivid_vid_cap_g_selection()
878 sel->r = dev->src_rect; in vivid_vid_cap_g_selection()
881 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
886 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
888 sel->r = dev->compose_cap; in vivid_vid_cap_g_selection()
891 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
893 sel->r = dev->fmt_cap_rect; in vivid_vid_cap_g_selection()
903 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_s_selection() local
904 struct v4l2_rect *crop = &dev->crop_cap; in vivid_vid_cap_s_selection()
905 struct v4l2_rect *compose = &dev->compose_cap; in vivid_vid_cap_s_selection()
906 unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_cap) ? 2 : 1; in vivid_vid_cap_s_selection()
909 if (!dev->has_crop_cap && !dev->has_compose_cap) in vivid_vid_cap_s_selection()
913 if (vivid_is_webcam(dev)) in vivid_vid_cap_s_selection()
918 if (!dev->has_crop_cap) in vivid_vid_cap_s_selection()
924 v4l2_rect_set_max_size(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
925 v4l2_rect_map_inside(&s->r, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
928 if (dev->has_scaler_cap) { in vivid_vid_cap_s_selection()
929 struct v4l2_rect fmt = dev->fmt_cap_rect; in vivid_vid_cap_s_selection()
942 if (!dev->has_compose_cap) in vivid_vid_cap_s_selection()
944 if (!v4l2_rect_same_size(&dev->fmt_cap_rect, &fmt) && in vivid_vid_cap_s_selection()
945 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
947 if (dev->has_compose_cap) { in vivid_vid_cap_s_selection()
952 dev->fmt_cap_rect = fmt; in vivid_vid_cap_s_selection()
953 tpg_s_buf_height(&dev->tpg, fmt.height); in vivid_vid_cap_s_selection()
954 } else if (dev->has_compose_cap) { in vivid_vid_cap_s_selection()
955 struct v4l2_rect fmt = dev->fmt_cap_rect; in vivid_vid_cap_s_selection()
958 if (!v4l2_rect_same_size(&dev->fmt_cap_rect, &fmt) && in vivid_vid_cap_s_selection()
959 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
961 dev->fmt_cap_rect = fmt; in vivid_vid_cap_s_selection()
962 tpg_s_buf_height(&dev->tpg, fmt.height); in vivid_vid_cap_s_selection()
964 v4l2_rect_map_inside(compose, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
966 if (!v4l2_rect_same_size(&s->r, &dev->fmt_cap_rect) && in vivid_vid_cap_s_selection()
967 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
969 v4l2_rect_set_size_to(&dev->fmt_cap_rect, &s->r); in vivid_vid_cap_s_selection()
971 v4l2_rect_map_inside(compose, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
972 tpg_s_buf_height(&dev->tpg, dev->fmt_cap_rect.height); in vivid_vid_cap_s_selection()
979 if (!dev->has_compose_cap) in vivid_vid_cap_s_selection()
985 v4l2_rect_set_max_size(&s->r, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
986 if (dev->has_scaler_cap) { in vivid_vid_cap_s_selection()
989 dev->src_rect.width * MAX_ZOOM, in vivid_vid_cap_s_selection()
990 (dev->src_rect.height / factor) * MAX_ZOOM in vivid_vid_cap_s_selection()
994 if (dev->has_crop_cap) { in vivid_vid_cap_s_selection()
1008 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
1010 } else if (dev->has_crop_cap) { in vivid_vid_cap_s_selection()
1013 v4l2_rect_set_max_size(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
1015 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
1019 v4l2_rect_set_size_to(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
1022 v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
1029 tpg_s_crop_compose(&dev->tpg, crop, compose); in vivid_vid_cap_s_selection()
1036 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_g_pixelaspect() local
1041 switch (vivid_get_pixel_aspect(dev)) { in vivid_vid_cap_g_pixelaspect()
1064 struct vivid_dev *dev = video_drvdata(file); in vidioc_enum_input() local
1066 if (inp->index >= dev->num_inputs) in vidioc_enum_input()
1070 switch (dev->input_type[inp->index]) { in vidioc_enum_input()
1073 dev->inst, dev->input_name_counter[inp->index]); in vidioc_enum_input()
1078 dev->inst, dev->input_name_counter[inp->index]); in vidioc_enum_input()
1081 if (dev->has_audio_inputs) in vidioc_enum_input()
1087 dev->inst, dev->input_name_counter[inp->index]); in vidioc_enum_input()
1089 if (dev->has_audio_inputs) in vidioc_enum_input()
1095 dev->inst, dev->input_name_counter[inp->index]); in vidioc_enum_input()
1097 if (dev->edid_blocks == 0 || in vidioc_enum_input()
1098 dev->dv_timings_signal_mode[dev->input] == NO_SIGNAL) in vidioc_enum_input()
1100 else if (dev->dv_timings_signal_mode[dev->input] == NO_LOCK || in vidioc_enum_input()
1101 dev->dv_timings_signal_mode[dev->input] == OUT_OF_RANGE) in vidioc_enum_input()
1105 if (dev->sensor_hflip) in vidioc_enum_input()
1107 if (dev->sensor_vflip) in vidioc_enum_input()
1109 if (dev->input == inp->index && vivid_is_sdtv_cap(dev)) { in vidioc_enum_input()
1110 if (dev->std_signal_mode[dev->input] == NO_SIGNAL) { in vidioc_enum_input()
1112 } else if (dev->std_signal_mode[dev->input] == NO_LOCK) { in vidioc_enum_input()
1114 } else if (vivid_is_tv_cap(dev)) { in vidioc_enum_input()
1115 switch (tpg_g_quality(&dev->tpg)) { in vidioc_enum_input()
1132 struct vivid_dev *dev = video_drvdata(file); in vidioc_g_input() local
1134 *i = dev->input; in vidioc_g_input()
1140 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_input() local
1141 struct v4l2_bt_timings *bt = &dev->dv_timings_cap[dev->input].bt; in vidioc_s_input()
1144 if (i >= dev->num_inputs) in vidioc_s_input()
1147 if (i == dev->input) in vidioc_s_input()
1150 if (vb2_is_busy(&dev->vb_vid_cap_q) || in vidioc_s_input()
1151 vb2_is_busy(&dev->vb_vbi_cap_q) || in vidioc_s_input()
1152 vb2_is_busy(&dev->vb_meta_cap_q)) in vidioc_s_input()
1155 dev->input = i; in vidioc_s_input()
1156 dev->vid_cap_dev.tvnorms = 0; in vidioc_s_input()
1157 if (dev->input_type[i] == TV || dev->input_type[i] == SVID) { in vidioc_s_input()
1158 dev->tv_audio_input = (dev->input_type[i] == TV) ? 0 : 1; in vidioc_s_input()
1159 dev->vid_cap_dev.tvnorms = V4L2_STD_ALL; in vidioc_s_input()
1161 dev->vbi_cap_dev.tvnorms = dev->vid_cap_dev.tvnorms; in vidioc_s_input()
1162 dev->meta_cap_dev.tvnorms = dev->vid_cap_dev.tvnorms; in vidioc_s_input()
1163 vivid_update_format_cap(dev, false); in vidioc_s_input()
1165 if (dev->colorspace) { in vidioc_s_input()
1166 switch (dev->input_type[i]) { in vidioc_s_input()
1168 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vidioc_s_input()
1172 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vidioc_s_input()
1176 if (dev->src_rect.width == 720 && dev->src_rect.height <= 576) in vidioc_s_input()
1177 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vidioc_s_input()
1179 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); in vidioc_s_input()
1181 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vidioc_s_input()
1194 brightness = 128 * i + dev->input_brightness[i]; in vidioc_s_input()
1195 v4l2_ctrl_modify_range(dev->brightness, in vidioc_s_input()
1197 v4l2_ctrl_s_ctrl(dev->brightness, brightness); in vidioc_s_input()
1200 v4l2_ctrl_activate(dev->ctrl_dv_timings_signal_mode, in vidioc_s_input()
1201 vivid_is_hdmi_cap(dev)); in vidioc_s_input()
1202 v4l2_ctrl_activate(dev->ctrl_dv_timings, vivid_is_hdmi_cap(dev) && in vidioc_s_input()
1203 dev->dv_timings_signal_mode[dev->input] == in vidioc_s_input()
1205 v4l2_ctrl_activate(dev->ctrl_std_signal_mode, vivid_is_sdtv_cap(dev)); in vidioc_s_input()
1206 v4l2_ctrl_activate(dev->ctrl_standard, vivid_is_sdtv_cap(dev) && in vidioc_s_input()
1207 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1209 if (vivid_is_hdmi_cap(dev)) { in vidioc_s_input()
1210 v4l2_ctrl_s_ctrl(dev->ctrl_dv_timings_signal_mode, in vidioc_s_input()
1211 dev->dv_timings_signal_mode[dev->input]); in vidioc_s_input()
1212 v4l2_ctrl_s_ctrl(dev->ctrl_dv_timings, in vidioc_s_input()
1213 dev->query_dv_timings[dev->input]); in vidioc_s_input()
1214 } else if (vivid_is_sdtv_cap(dev)) { in vidioc_s_input()
1215 v4l2_ctrl_s_ctrl(dev->ctrl_std_signal_mode, in vidioc_s_input()
1216 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1217 v4l2_ctrl_s_ctrl(dev->ctrl_standard, in vidioc_s_input()
1218 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1234 struct vivid_dev *dev = video_drvdata(file); in vidioc_g_audio() local
1236 if (!vivid_is_sdtv_cap(dev)) in vidioc_g_audio()
1238 *vin = vivid_audio_inputs[dev->tv_audio_input]; in vidioc_g_audio()
1244 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_audio() local
1246 if (!vivid_is_sdtv_cap(dev)) in vidioc_s_audio()
1250 dev->tv_audio_input = vin->index; in vidioc_s_audio()
1256 struct vivid_dev *dev = video_drvdata(file); in vivid_video_g_frequency() local
1260 vf->frequency = dev->tv_freq; in vivid_video_g_frequency()
1266 struct vivid_dev *dev = video_drvdata(file); in vivid_video_s_frequency() local
1270 dev->tv_freq = clamp_t(unsigned, vf->frequency, MIN_TV_FREQ, MAX_TV_FREQ); in vivid_video_s_frequency()
1271 if (vivid_is_tv_cap(dev)) in vivid_video_s_frequency()
1272 vivid_update_quality(dev); in vivid_video_s_frequency()
1278 struct vivid_dev *dev = video_drvdata(file); in vivid_video_s_tuner() local
1284 dev->tv_audmode = vt->audmode; in vivid_video_s_tuner()
1290 struct vivid_dev *dev = video_drvdata(file); in vivid_video_g_tuner() local
1298 vt->audmode = dev->tv_audmode; in vivid_video_g_tuner()
1301 qual = vivid_get_quality(dev, &vt->afc); in vivid_video_g_tuner()
1313 unsigned int channel_nr = dev->tv_freq / (6 * 16); in vivid_video_g_tuner()
1315 (dev->std_cap[dev->input] & V4L2_STD_NTSC_M) ? 4 : 3; in vivid_video_g_tuner()
1325 if (dev->std_cap[dev->input] & V4L2_STD_NTSC_M) in vivid_video_g_tuner()
1381 struct vivid_dev *dev = video_drvdata(file); in vidioc_querystd() local
1382 unsigned int last = dev->query_std_last[dev->input]; in vidioc_querystd()
1384 if (!vivid_is_sdtv_cap(dev)) in vidioc_querystd()
1386 if (dev->std_signal_mode[dev->input] == NO_SIGNAL || in vidioc_querystd()
1387 dev->std_signal_mode[dev->input] == NO_LOCK) { in vidioc_querystd()
1391 if (vivid_is_tv_cap(dev) && tpg_g_quality(&dev->tpg) == TPG_QUAL_NOISE) { in vidioc_querystd()
1393 } else if (dev->std_signal_mode[dev->input] == CURRENT_STD) { in vidioc_querystd()
1394 *id = dev->std_cap[dev->input]; in vidioc_querystd()
1395 } else if (dev->std_signal_mode[dev->input] == SELECTED_STD) { in vidioc_querystd()
1396 *id = dev->query_std[dev->input]; in vidioc_querystd()
1399 dev->query_std_last[dev->input] = in vidioc_querystd()
1408 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_s_std() local
1410 if (!vivid_is_sdtv_cap(dev)) in vivid_vid_cap_s_std()
1412 if (dev->std_cap[dev->input] == id) in vivid_vid_cap_s_std()
1414 if (vb2_is_busy(&dev->vb_vid_cap_q) || vb2_is_busy(&dev->vb_vbi_cap_q)) in vivid_vid_cap_s_std()
1416 dev->std_cap[dev->input] = id; in vivid_vid_cap_s_std()
1417 vivid_update_format_cap(dev, false); in vivid_vid_cap_s_std()
1484 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_s_dv_timings() local
1486 if (!vivid_is_hdmi_cap(dev)) in vivid_vid_cap_s_dv_timings()
1493 if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap[dev->input], in vivid_vid_cap_s_dv_timings()
1496 if (vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_dv_timings()
1499 dev->dv_timings_cap[dev->input] = *timings; in vivid_vid_cap_s_dv_timings()
1500 vivid_update_format_cap(dev, false); in vivid_vid_cap_s_dv_timings()
1507 struct vivid_dev *dev = video_drvdata(file); in vidioc_query_dv_timings() local
1508 unsigned int input = dev->input; in vidioc_query_dv_timings()
1509 unsigned int last = dev->query_dv_timings_last[input]; in vidioc_query_dv_timings()
1511 if (!vivid_is_hdmi_cap(dev)) in vidioc_query_dv_timings()
1513 if (dev->dv_timings_signal_mode[input] == NO_SIGNAL || in vidioc_query_dv_timings()
1514 dev->edid_blocks == 0) in vidioc_query_dv_timings()
1516 if (dev->dv_timings_signal_mode[input] == NO_LOCK) in vidioc_query_dv_timings()
1518 if (dev->dv_timings_signal_mode[input] == OUT_OF_RANGE) { in vidioc_query_dv_timings()
1522 if (dev->dv_timings_signal_mode[input] == CURRENT_DV_TIMINGS) { in vidioc_query_dv_timings()
1523 *timings = dev->dv_timings_cap[input]; in vidioc_query_dv_timings()
1524 } else if (dev->dv_timings_signal_mode[input] == in vidioc_query_dv_timings()
1527 v4l2_dv_timings_presets[dev->query_dv_timings[input]]; in vidioc_query_dv_timings()
1531 dev->query_dv_timings_last[input] = in vidioc_query_dv_timings()
1532 (last + 1) % dev->query_dv_timings_size; in vidioc_query_dv_timings()
1537 void vivid_update_outputs(struct vivid_dev *dev) in vivid_update_outputs() argument
1541 if (!dev || !dev->num_outputs) in vivid_update_outputs()
1543 for (unsigned int i = 0, j = 0; i < dev->num_outputs; i++) { in vivid_update_outputs()
1544 if (dev->output_type[i] != HDMI) in vivid_update_outputs()
1547 struct vivid_dev *dev_rx = dev->output_to_input_instance[i]; in vivid_update_outputs()
1553 v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, edid_present); in vivid_update_outputs()
1554 v4l2_ctrl_s_ctrl(dev->ctrl_tx_hotplug, edid_present); in vivid_update_outputs()
1555 v4l2_ctrl_s_ctrl(dev->ctrl_tx_rxsense, edid_present); in vivid_update_outputs()
1558 void vivid_update_connected_outputs(struct vivid_dev *dev) in vivid_update_connected_outputs() argument
1560 u16 phys_addr = cec_get_edid_phys_addr(dev->edid, dev->edid_blocks * 128, NULL); in vivid_update_connected_outputs()
1562 for (unsigned int i = 0, j = 0; i < dev->num_inputs; i++) { in vivid_update_connected_outputs()
1564 dev->input_is_connected_to_output[i]; in vivid_update_connected_outputs()
1566 if (dev->input_type[i] != HDMI) in vivid_update_connected_outputs()
1581 if (dev->edid_blocks) { in vivid_update_connected_outputs()
1594 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_edid() local
1599 if (edid->pad >= dev->num_inputs) in vidioc_s_edid()
1601 if (dev->input_type[edid->pad] != HDMI || edid->start_block) in vidioc_s_edid()
1604 if (vb2_is_busy(&dev->vb_vid_cap_q)) in vidioc_s_edid()
1606 dev->edid_blocks = 0; in vidioc_s_edid()
1607 vivid_update_connected_outputs(dev); in vidioc_s_edid()
1610 if (edid->blocks > dev->edid_max_blocks) { in vidioc_s_edid()
1611 edid->blocks = dev->edid_max_blocks; in vidioc_s_edid()
1619 if (vb2_is_busy(&dev->vb_vid_cap_q)) in vidioc_s_edid()
1622 dev->edid_blocks = edid->blocks; in vidioc_s_edid()
1623 memcpy(dev->edid, edid->edid, edid->blocks * 128); in vidioc_s_edid()
1625 vivid_update_connected_outputs(dev); in vidioc_s_edid()
1632 struct vivid_dev *dev = video_drvdata(file); in vidioc_enum_framesizes() local
1634 if (!vivid_is_webcam(dev) && !dev->has_scaler_cap) in vidioc_enum_framesizes()
1636 if (vivid_get_format(dev, fsize->pixel_format) == NULL) in vidioc_enum_framesizes()
1638 if (vivid_is_webcam(dev)) { in vidioc_enum_framesizes()
1661 struct vivid_dev *dev = video_drvdata(file); in vidioc_enum_frameintervals() local
1665 fmt = vivid_get_format(dev, fival->pixel_format); in vidioc_enum_frameintervals()
1669 if (!vivid_is_webcam(dev)) { in vidioc_enum_frameintervals()
1677 fival->discrete = dev->timeperframe_vid_cap; in vidioc_enum_frameintervals()
1687 if (fival->index >= webcam_ival_count(dev, i)) in vidioc_enum_frameintervals()
1697 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_g_parm() local
1699 if (parm->type != (dev->multiplanar ? in vivid_vid_cap_g_parm()
1705 parm->parm.capture.timeperframe = dev->timeperframe_vid_cap; in vivid_vid_cap_g_parm()
1713 struct vivid_dev *dev = video_drvdata(file); in vivid_vid_cap_s_parm() local
1714 unsigned int ival_sz = webcam_ival_count(dev, dev->webcam_size_idx); in vivid_vid_cap_s_parm()
1718 if (parm->type != (dev->multiplanar ? in vivid_vid_cap_s_parm()
1722 if (!vivid_is_webcam(dev)) in vivid_vid_cap_s_parm()
1734 dev->webcam_ival_idx = i; in vivid_vid_cap_s_parm()
1735 tpf = webcam_intervals[dev->webcam_ival_idx]; in vivid_vid_cap_s_parm()
1738 dev->cap_seq_resync = true; in vivid_vid_cap_s_parm()
1739 dev->timeperframe_vid_cap = tpf; in vivid_vid_cap_s_parm()