Lines Matching +full:standard +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0-only
3 * vivid-vid-cap.c - video capture support functions.
13 #include <linux/v4l2-dv-timings.h>
14 #include <media/v4l2-common.h>
15 #include <media/v4l2-event.h>
16 #include <media/v4l2-dv-timings.h>
17 #include <media/v4l2-rect.h>
19 #include "vivid-core.h"
20 #include "vivid-vid-common.h"
21 #include "vivid-kthread-cap.h"
22 #include "vivid-vid-cap.h"
87 unsigned buffers = tpg_g_buffers(&dev->tpg); in vid_cap_queue_setup()
88 unsigned h = dev->fmt_cap_rect.height; in vid_cap_queue_setup()
91 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { in vid_cap_queue_setup()
97 return -EINVAL; in vid_cap_queue_setup()
100 if (dev->queue_setup_error) { in vid_cap_queue_setup()
105 dev->queue_setup_error = false; in vid_cap_queue_setup()
106 return -EINVAL; in vid_cap_queue_setup()
114 return -EINVAL; in vid_cap_queue_setup()
116 if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h + in vid_cap_queue_setup()
117 dev->fmt_cap->data_offset[p]) in vid_cap_queue_setup()
118 return -EINVAL; in vid_cap_queue_setup()
122 sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / in vid_cap_queue_setup()
123 dev->fmt_cap->vdownsampling[p] + in vid_cap_queue_setup()
124 dev->fmt_cap->data_offset[p]; in vid_cap_queue_setup()
127 if (vq->num_buffers + *nbuffers < 2) in vid_cap_queue_setup()
128 *nbuffers = 2 - vq->num_buffers; in vid_cap_queue_setup()
141 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_prepare()
143 unsigned buffers = tpg_g_buffers(&dev->tpg); in vid_cap_buf_prepare()
148 if (WARN_ON(NULL == dev->fmt_cap)) in vid_cap_buf_prepare()
149 return -EINVAL; in vid_cap_buf_prepare()
151 if (dev->buf_prepare_error) { in vid_cap_buf_prepare()
156 dev->buf_prepare_error = false; in vid_cap_buf_prepare()
157 return -EINVAL; in vid_cap_buf_prepare()
160 size = (tpg_g_line_width(&dev->tpg, p) * in vid_cap_buf_prepare()
161 dev->fmt_cap_rect.height) / in vid_cap_buf_prepare()
162 dev->fmt_cap->vdownsampling[p] + in vid_cap_buf_prepare()
163 dev->fmt_cap->data_offset[p]; in vid_cap_buf_prepare()
168 return -EINVAL; in vid_cap_buf_prepare()
172 vb->planes[p].data_offset = dev->fmt_cap->data_offset[p]; in vid_cap_buf_prepare()
181 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_finish()
182 struct v4l2_timecode *tc = &vbuf->timecode; in vid_cap_buf_finish()
184 unsigned seq = vbuf->sequence; in vid_cap_buf_finish()
193 vbuf->flags |= V4L2_BUF_FLAG_TIMECODE; in vid_cap_buf_finish()
194 if (dev->std_cap[dev->input] & V4L2_STD_525_60) in vid_cap_buf_finish()
196 tc->type = (fps == 30) ? V4L2_TC_TYPE_30FPS : V4L2_TC_TYPE_25FPS; in vid_cap_buf_finish()
197 tc->flags = 0; in vid_cap_buf_finish()
198 tc->frames = seq % fps; in vid_cap_buf_finish()
199 tc->seconds = (seq / fps) % 60; in vid_cap_buf_finish()
200 tc->minutes = (seq / (60 * fps)) % 60; in vid_cap_buf_finish()
201 tc->hours = (seq / (60 * 60 * fps)) % 24; in vid_cap_buf_finish()
207 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_queue()
212 spin_lock(&dev->slock); in vid_cap_buf_queue()
213 list_add_tail(&buf->list, &dev->vid_cap_active); in vid_cap_buf_queue()
214 spin_unlock(&dev->slock); in vid_cap_buf_queue()
223 if (vb2_is_streaming(&dev->vb_vid_out_q)) in vid_cap_start_streaming()
224 dev->can_loop_video = vivid_vid_can_loop(dev); in vid_cap_start_streaming()
226 dev->vid_cap_seq_count = 0; in vid_cap_start_streaming()
229 dev->must_blank[i] = tpg_g_perc_fill(&dev->tpg) < 100; in vid_cap_start_streaming()
230 if (dev->start_streaming_error) { in vid_cap_start_streaming()
231 dev->start_streaming_error = false; in vid_cap_start_streaming()
232 err = -EINVAL; in vid_cap_start_streaming()
234 err = vivid_start_generating_vid_cap(dev, &dev->vid_cap_streaming); in vid_cap_start_streaming()
239 list_for_each_entry_safe(buf, tmp, &dev->vid_cap_active, list) { in vid_cap_start_streaming()
240 list_del(&buf->list); in vid_cap_start_streaming()
241 vb2_buffer_done(&buf->vb.vb2_buf, in vid_cap_start_streaming()
254 vivid_stop_generating_vid_cap(dev, &dev->vid_cap_streaming); in vid_cap_stop_streaming()
255 dev->can_loop_video = false; in vid_cap_stop_streaming()
260 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in vid_cap_buf_request_complete()
262 v4l2_ctrl_request_complete(vb->req_obj.req, &dev->ctrl_hdl_vid_cap); in vid_cap_buf_request_complete()
286 if (dev->loop_video && (vivid_is_svid_cap(dev) || vivid_is_hdmi_cap(dev))) { in vivid_update_quality()
291 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
295 VIVID_INVALID_SIGNAL(dev->dv_timings_signal_mode[dev->input])) { in vivid_update_quality()
296 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
300 VIVID_INVALID_SIGNAL(dev->std_signal_mode[dev->input])) { in vivid_update_quality()
301 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, 0); in vivid_update_quality()
305 tpg_s_quality(&dev->tpg, TPG_QUAL_COLOR, 0); in vivid_update_quality()
311 * From +/- 0.25 MHz around the channel there is color, and from in vivid_update_quality()
312 * +/- 1 MHz there is grayscale (chroma is lost). in vivid_update_quality()
315 freq_modulus = (dev->tv_freq - 676 /* (43.25-1) * 16 */) % (6 * 16); in vivid_update_quality()
317 tpg_s_quality(&dev->tpg, TPG_QUAL_NOISE, in vivid_update_quality()
318 next_pseudo_random32(dev->tv_freq ^ 0x55) & 0x3f); in vivid_update_quality()
322 tpg_s_quality(&dev->tpg, TPG_QUAL_GRAY, 0); in vivid_update_quality()
324 tpg_s_quality(&dev->tpg, TPG_QUAL_COLOR, 0); in vivid_update_quality()
336 if (tpg_g_quality(&dev->tpg) == TPG_QUAL_COLOR || in vivid_get_quality()
337 tpg_g_quality(&dev->tpg) == TPG_QUAL_NOISE) in vivid_get_quality()
338 return tpg_g_quality(&dev->tpg); in vivid_get_quality()
342 * From +/- 0.25 MHz around the channel there is color, and from in vivid_get_quality()
343 * +/- 1 MHz there is grayscale (chroma is lost). in vivid_get_quality()
346 freq_modulus = (dev->tv_freq - 676 /* (43.25-1) * 16 */) % (6 * 16); in vivid_get_quality()
348 *afc = freq_modulus - 1 * 16; in vivid_get_quality()
355 return dev->std_aspect_ratio[dev->input]; in vivid_get_video_aspect()
358 return dev->dv_timings_aspect_ratio[dev->input]; in vivid_get_video_aspect()
366 return (dev->std_cap[dev->input] & V4L2_STD_525_60) ? in vivid_get_pixel_aspect()
370 dev->src_rect.width == 720 && dev->src_rect.height <= 576) in vivid_get_pixel_aspect()
371 return dev->src_rect.height == 480 ? in vivid_get_pixel_aspect()
379 * changing inputs, standard, timings, etc.
383 struct v4l2_bt_timings *bt = &dev->dv_timings_cap[dev->input].bt; in vivid_update_format_cap()
387 switch (dev->input_type[dev->input]) { in vivid_update_format_cap()
390 dev->src_rect.width = webcam_sizes[dev->webcam_size_idx].width; in vivid_update_format_cap()
391 dev->src_rect.height = webcam_sizes[dev->webcam_size_idx].height; in vivid_update_format_cap()
392 dev->timeperframe_vid_cap = webcam_intervals[dev->webcam_ival_idx]; in vivid_update_format_cap()
393 dev->field_cap = V4L2_FIELD_NONE; in vivid_update_format_cap()
394 tpg_s_rgb_range(&dev->tpg, V4L2_DV_RGB_RANGE_AUTO); in vivid_update_format_cap()
398 dev->field_cap = dev->tv_field_cap; in vivid_update_format_cap()
399 dev->src_rect.width = 720; in vivid_update_format_cap()
400 if (dev->std_cap[dev->input] & V4L2_STD_525_60) { in vivid_update_format_cap()
401 dev->src_rect.height = 480; in vivid_update_format_cap()
402 dev->timeperframe_vid_cap = (struct v4l2_fract) { 1001, 30000 }; in vivid_update_format_cap()
403 dev->service_set_cap = V4L2_SLICED_CAPTION_525; in vivid_update_format_cap()
405 dev->src_rect.height = 576; in vivid_update_format_cap()
406 dev->timeperframe_vid_cap = (struct v4l2_fract) { 1000, 25000 }; in vivid_update_format_cap()
407 dev->service_set_cap = V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B; in vivid_update_format_cap()
409 tpg_s_rgb_range(&dev->tpg, V4L2_DV_RGB_RANGE_AUTO); in vivid_update_format_cap()
412 dev->src_rect.width = bt->width; in vivid_update_format_cap()
413 dev->src_rect.height = bt->height; in vivid_update_format_cap()
415 if (dev->reduced_fps && can_reduce_fps(bt)) { in vivid_update_format_cap()
416 pixelclock = div_u64(bt->pixelclock * 1000, 1001); in vivid_update_format_cap()
417 bt->flags |= V4L2_DV_FL_REDUCED_FPS; in vivid_update_format_cap()
419 pixelclock = bt->pixelclock; in vivid_update_format_cap()
420 bt->flags &= ~V4L2_DV_FL_REDUCED_FPS; in vivid_update_format_cap()
422 dev->timeperframe_vid_cap = (struct v4l2_fract) { in vivid_update_format_cap()
425 if (bt->interlaced) in vivid_update_format_cap()
426 dev->field_cap = V4L2_FIELD_ALTERNATE; in vivid_update_format_cap()
428 dev->field_cap = V4L2_FIELD_NONE; in vivid_update_format_cap()
434 if (keep_controls || !dev->colorspace) in vivid_update_format_cap()
436 if (bt->flags & V4L2_DV_FL_IS_CE_VIDEO) { in vivid_update_format_cap()
437 if (bt->width == 720 && bt->height <= 576) in vivid_update_format_cap()
438 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vivid_update_format_cap()
440 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); in vivid_update_format_cap()
441 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1); in vivid_update_format_cap()
443 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vivid_update_format_cap()
444 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0); in vivid_update_format_cap()
446 tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap)); in vivid_update_format_cap()
449 vfree(dev->bitmap_cap); in vivid_update_format_cap()
450 dev->bitmap_cap = NULL; in vivid_update_format_cap()
452 tpg_reset_source(&dev->tpg, dev->src_rect.width, dev->src_rect.height, dev->field_cap); in vivid_update_format_cap()
453 dev->crop_cap = dev->src_rect; in vivid_update_format_cap()
454 dev->crop_bounds_cap = dev->src_rect; in vivid_update_format_cap()
455 dev->compose_cap = dev->crop_cap; in vivid_update_format_cap()
456 if (V4L2_FIELD_HAS_T_OR_B(dev->field_cap)) in vivid_update_format_cap()
457 dev->compose_cap.height /= 2; in vivid_update_format_cap()
458 dev->fmt_cap_rect = dev->compose_cap; in vivid_update_format_cap()
459 tpg_s_video_aspect(&dev->tpg, vivid_get_video_aspect(dev)); in vivid_update_format_cap()
460 tpg_s_pixel_aspect(&dev->tpg, vivid_get_pixel_aspect(dev)); in vivid_update_format_cap()
461 tpg_update_mv_step(&dev->tpg); in vivid_update_format_cap()
483 return dev->dv_timings_cap[dev->input].bt.interlaced ? in vivid_field_cap()
490 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) in vivid_colorspace_cap()
491 return tpg_g_colorspace(&dev->tpg); in vivid_colorspace_cap()
492 return dev->colorspace_out; in vivid_colorspace_cap()
497 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) in vivid_xfer_func_cap()
498 return tpg_g_xfer_func(&dev->tpg); in vivid_xfer_func_cap()
499 return dev->xfer_func_out; in vivid_xfer_func_cap()
504 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) in vivid_ycbcr_enc_cap()
505 return tpg_g_ycbcr_enc(&dev->tpg); in vivid_ycbcr_enc_cap()
506 return dev->ycbcr_enc_out; in vivid_ycbcr_enc_cap()
511 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) in vivid_hsv_enc_cap()
512 return tpg_g_hsv_enc(&dev->tpg); in vivid_hsv_enc_cap()
513 return dev->hsv_enc_out; in vivid_hsv_enc_cap()
518 if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) in vivid_quantization_cap()
519 return tpg_g_quantization(&dev->tpg); in vivid_quantization_cap()
520 return dev->quantization_out; in vivid_quantization_cap()
527 struct v4l2_pix_format_mplane *mp = &f->fmt.pix_mp; in vivid_g_fmt_vid_cap()
530 mp->width = dev->fmt_cap_rect.width; in vivid_g_fmt_vid_cap()
531 mp->height = dev->fmt_cap_rect.height; in vivid_g_fmt_vid_cap()
532 mp->field = dev->field_cap; in vivid_g_fmt_vid_cap()
533 mp->pixelformat = dev->fmt_cap->fourcc; in vivid_g_fmt_vid_cap()
534 mp->colorspace = vivid_colorspace_cap(dev); in vivid_g_fmt_vid_cap()
535 mp->xfer_func = vivid_xfer_func_cap(dev); in vivid_g_fmt_vid_cap()
536 if (dev->fmt_cap->color_enc == TGP_COLOR_ENC_HSV) in vivid_g_fmt_vid_cap()
537 mp->hsv_enc = vivid_hsv_enc_cap(dev); in vivid_g_fmt_vid_cap()
539 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_g_fmt_vid_cap()
540 mp->quantization = vivid_quantization_cap(dev); in vivid_g_fmt_vid_cap()
541 mp->num_planes = dev->fmt_cap->buffers; in vivid_g_fmt_vid_cap()
542 for (p = 0; p < mp->num_planes; p++) { in vivid_g_fmt_vid_cap()
543 mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p); in vivid_g_fmt_vid_cap()
544 mp->plane_fmt[p].sizeimage = in vivid_g_fmt_vid_cap()
545 (tpg_g_line_width(&dev->tpg, p) * mp->height) / in vivid_g_fmt_vid_cap()
546 dev->fmt_cap->vdownsampling[p] + in vivid_g_fmt_vid_cap()
547 dev->fmt_cap->data_offset[p]; in vivid_g_fmt_vid_cap()
555 struct v4l2_pix_format_mplane *mp = &f->fmt.pix_mp; in vivid_try_fmt_vid_cap()
556 struct v4l2_plane_pix_format *pfmt = mp->plane_fmt; in vivid_try_fmt_vid_cap()
563 bool user_set_csc = !!(mp->flags & V4L2_PIX_FMT_FLAG_SET_CSC); in vivid_try_fmt_vid_cap()
565 fmt = vivid_get_format(dev, mp->pixelformat); in vivid_try_fmt_vid_cap()
568 mp->pixelformat); in vivid_try_fmt_vid_cap()
569 mp->pixelformat = V4L2_PIX_FMT_YUYV; in vivid_try_fmt_vid_cap()
570 fmt = vivid_get_format(dev, mp->pixelformat); in vivid_try_fmt_vid_cap()
573 mp->field = vivid_field_cap(dev, mp->field); in vivid_try_fmt_vid_cap()
578 height, mp->width, mp->height); in vivid_try_fmt_vid_cap()
580 w = sz->width; in vivid_try_fmt_vid_cap()
581 h = sz->height; in vivid_try_fmt_vid_cap()
584 h = (dev->std_cap[dev->input] & V4L2_STD_525_60) ? 480 : 576; in vivid_try_fmt_vid_cap()
586 w = dev->src_rect.width; in vivid_try_fmt_vid_cap()
587 h = dev->src_rect.height; in vivid_try_fmt_vid_cap()
589 if (V4L2_FIELD_HAS_T_OR_B(mp->field)) in vivid_try_fmt_vid_cap()
592 (!dev->has_scaler_cap && !dev->has_crop_cap && !dev->has_compose_cap)) { in vivid_try_fmt_vid_cap()
593 mp->width = w; in vivid_try_fmt_vid_cap()
594 mp->height = h / factor; in vivid_try_fmt_vid_cap()
596 struct v4l2_rect r = { 0, 0, mp->width, mp->height * factor }; in vivid_try_fmt_vid_cap()
600 if (dev->has_scaler_cap && !dev->has_compose_cap) { in vivid_try_fmt_vid_cap()
604 } else if (!dev->has_scaler_cap && dev->has_crop_cap && !dev->has_compose_cap) { in vivid_try_fmt_vid_cap()
605 v4l2_rect_set_max_size(&r, &dev->src_rect); in vivid_try_fmt_vid_cap()
606 } else if (!dev->has_scaler_cap && !dev->has_crop_cap) { in vivid_try_fmt_vid_cap()
607 v4l2_rect_set_min_size(&r, &dev->src_rect); in vivid_try_fmt_vid_cap()
609 mp->width = r.width; in vivid_try_fmt_vid_cap()
610 mp->height = r.height / factor; in vivid_try_fmt_vid_cap()
615 mp->num_planes = fmt->buffers; in vivid_try_fmt_vid_cap()
616 for (p = 0; p < fmt->buffers; p++) { in vivid_try_fmt_vid_cap()
618 bytesperline = (mp->width * fmt->bit_depth[p]) >> 3; in vivid_try_fmt_vid_cap()
620 max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[p]) >> 3; in vivid_try_fmt_vid_cap()
627 pfmt[p].sizeimage = (pfmt[p].bytesperline * mp->height) / in vivid_try_fmt_vid_cap()
628 fmt->vdownsampling[p] + fmt->data_offset[p]; in vivid_try_fmt_vid_cap()
632 for (p = fmt->buffers; p < fmt->planes; p++) in vivid_try_fmt_vid_cap()
633 pfmt[0].sizeimage += (pfmt[0].bytesperline * mp->height * in vivid_try_fmt_vid_cap()
634 (fmt->bit_depth[p] / fmt->vdownsampling[p])) / in vivid_try_fmt_vid_cap()
635 (fmt->bit_depth[0] / fmt->vdownsampling[0]); in vivid_try_fmt_vid_cap()
637 if (!user_set_csc || !v4l2_is_colorspace_valid(mp->colorspace)) in vivid_try_fmt_vid_cap()
638 mp->colorspace = vivid_colorspace_cap(dev); in vivid_try_fmt_vid_cap()
640 if (!user_set_csc || !v4l2_is_xfer_func_valid(mp->xfer_func)) in vivid_try_fmt_vid_cap()
641 mp->xfer_func = vivid_xfer_func_cap(dev); in vivid_try_fmt_vid_cap()
643 if (fmt->color_enc == TGP_COLOR_ENC_HSV) { in vivid_try_fmt_vid_cap()
644 if (!user_set_csc || !v4l2_is_hsv_enc_valid(mp->hsv_enc)) in vivid_try_fmt_vid_cap()
645 mp->hsv_enc = vivid_hsv_enc_cap(dev); in vivid_try_fmt_vid_cap()
646 } else if (fmt->color_enc == TGP_COLOR_ENC_YCBCR) { in vivid_try_fmt_vid_cap()
647 if (!user_set_csc || !v4l2_is_ycbcr_enc_valid(mp->ycbcr_enc)) in vivid_try_fmt_vid_cap()
648 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_try_fmt_vid_cap()
650 mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); in vivid_try_fmt_vid_cap()
653 if (fmt->color_enc == TGP_COLOR_ENC_YCBCR || in vivid_try_fmt_vid_cap()
654 fmt->color_enc == TGP_COLOR_ENC_RGB) { in vivid_try_fmt_vid_cap()
655 if (!user_set_csc || !v4l2_is_quant_valid(mp->quantization)) in vivid_try_fmt_vid_cap()
656 mp->quantization = vivid_quantization_cap(dev); in vivid_try_fmt_vid_cap()
658 mp->quantization = vivid_quantization_cap(dev); in vivid_try_fmt_vid_cap()
661 memset(mp->reserved, 0, sizeof(mp->reserved)); in vivid_try_fmt_vid_cap()
668 struct v4l2_pix_format_mplane *mp = &f->fmt.pix_mp; in vivid_s_fmt_vid_cap()
670 struct v4l2_rect *crop = &dev->crop_cap; in vivid_s_fmt_vid_cap()
671 struct v4l2_rect *compose = &dev->compose_cap; in vivid_s_fmt_vid_cap()
672 struct vb2_queue *q = &dev->vb_vid_cap_q; in vivid_s_fmt_vid_cap()
683 return -EBUSY; in vivid_s_fmt_vid_cap()
686 if (dev->overlay_cap_owner && dev->fb_cap.fmt.pixelformat != mp->pixelformat) { in vivid_s_fmt_vid_cap()
688 return -EBUSY; in vivid_s_fmt_vid_cap()
691 dev->fmt_cap = vivid_get_format(dev, mp->pixelformat); in vivid_s_fmt_vid_cap()
692 if (V4L2_FIELD_HAS_T_OR_B(mp->field)) in vivid_s_fmt_vid_cap()
698 (dev->has_scaler_cap || dev->has_crop_cap || dev->has_compose_cap)) { in vivid_s_fmt_vid_cap()
699 struct v4l2_rect r = { 0, 0, mp->width, mp->height }; in vivid_s_fmt_vid_cap()
701 if (dev->has_scaler_cap) { in vivid_s_fmt_vid_cap()
702 if (dev->has_compose_cap) in vivid_s_fmt_vid_cap()
706 if (dev->has_crop_cap && !dev->has_compose_cap) { in vivid_s_fmt_vid_cap()
720 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
721 } else if (dev->has_crop_cap) { in vivid_s_fmt_vid_cap()
724 compose->width / MAX_ZOOM, in vivid_s_fmt_vid_cap()
725 factor * compose->height / MAX_ZOOM in vivid_s_fmt_vid_cap()
729 compose->width * MAX_ZOOM, in vivid_s_fmt_vid_cap()
730 factor * compose->height * MAX_ZOOM in vivid_s_fmt_vid_cap()
735 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
737 } else if (dev->has_crop_cap && !dev->has_compose_cap) { in vivid_s_fmt_vid_cap()
740 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
744 } else if (!dev->has_crop_cap) { in vivid_s_fmt_vid_cap()
749 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_s_fmt_vid_cap()
750 compose->top *= factor; in vivid_s_fmt_vid_cap()
751 compose->height *= factor; in vivid_s_fmt_vid_cap()
754 compose->top /= factor; in vivid_s_fmt_vid_cap()
755 compose->height /= factor; in vivid_s_fmt_vid_cap()
760 if (webcam_sizes[i].width == mp->width && in vivid_s_fmt_vid_cap()
761 webcam_sizes[i].height == mp->height) in vivid_s_fmt_vid_cap()
763 dev->webcam_size_idx = i; in vivid_s_fmt_vid_cap()
764 if (dev->webcam_ival_idx >= 2 * (VIVID_WEBCAM_SIZES - i)) in vivid_s_fmt_vid_cap()
765 dev->webcam_ival_idx = 2 * (VIVID_WEBCAM_SIZES - i) - 1; in vivid_s_fmt_vid_cap()
768 struct v4l2_rect r = { 0, 0, mp->width, mp->height }; in vivid_s_fmt_vid_cap()
775 dev->fmt_cap_rect.width = mp->width; in vivid_s_fmt_vid_cap()
776 dev->fmt_cap_rect.height = mp->height; in vivid_s_fmt_vid_cap()
777 tpg_s_buf_height(&dev->tpg, mp->height); in vivid_s_fmt_vid_cap()
778 tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc); in vivid_s_fmt_vid_cap()
779 for (p = 0; p < tpg_g_buffers(&dev->tpg); p++) in vivid_s_fmt_vid_cap()
780 tpg_s_bytesperline(&dev->tpg, p, mp->plane_fmt[p].bytesperline); in vivid_s_fmt_vid_cap()
781 dev->field_cap = mp->field; in vivid_s_fmt_vid_cap()
782 if (dev->field_cap == V4L2_FIELD_ALTERNATE) in vivid_s_fmt_vid_cap()
783 tpg_s_field(&dev->tpg, V4L2_FIELD_TOP, true); in vivid_s_fmt_vid_cap()
785 tpg_s_field(&dev->tpg, dev->field_cap, false); in vivid_s_fmt_vid_cap()
786 tpg_s_crop_compose(&dev->tpg, &dev->crop_cap, &dev->compose_cap); in vivid_s_fmt_vid_cap()
788 dev->tv_field_cap = mp->field; in vivid_s_fmt_vid_cap()
789 tpg_update_mv_step(&dev->tpg); in vivid_s_fmt_vid_cap()
790 dev->tpg.colorspace = mp->colorspace; in vivid_s_fmt_vid_cap()
791 dev->tpg.xfer_func = mp->xfer_func; in vivid_s_fmt_vid_cap()
792 if (dev->fmt_cap->color_enc == TGP_COLOR_ENC_YCBCR) in vivid_s_fmt_vid_cap()
793 dev->tpg.ycbcr_enc = mp->ycbcr_enc; in vivid_s_fmt_vid_cap()
795 dev->tpg.hsv_enc = mp->hsv_enc; in vivid_s_fmt_vid_cap()
796 dev->tpg.quantization = mp->quantization; in vivid_s_fmt_vid_cap()
806 if (!dev->multiplanar) in vidioc_g_fmt_vid_cap_mplane()
807 return -ENOTTY; in vidioc_g_fmt_vid_cap_mplane()
816 if (!dev->multiplanar) in vidioc_try_fmt_vid_cap_mplane()
817 return -ENOTTY; in vidioc_try_fmt_vid_cap_mplane()
826 if (!dev->multiplanar) in vidioc_s_fmt_vid_cap_mplane()
827 return -ENOTTY; in vidioc_s_fmt_vid_cap_mplane()
836 if (dev->multiplanar) in vidioc_g_fmt_vid_cap()
837 return -ENOTTY; in vidioc_g_fmt_vid_cap()
846 if (dev->multiplanar) in vidioc_try_fmt_vid_cap()
847 return -ENOTTY; in vidioc_try_fmt_vid_cap()
856 if (dev->multiplanar) in vidioc_s_fmt_vid_cap()
857 return -ENOTTY; in vidioc_s_fmt_vid_cap()
866 if (!dev->has_crop_cap && !dev->has_compose_cap) in vivid_vid_cap_g_selection()
867 return -ENOTTY; in vivid_vid_cap_g_selection()
868 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vivid_vid_cap_g_selection()
869 return -EINVAL; in vivid_vid_cap_g_selection()
871 return -ENODATA; in vivid_vid_cap_g_selection()
873 sel->r.left = sel->r.top = 0; in vivid_vid_cap_g_selection()
874 switch (sel->target) { in vivid_vid_cap_g_selection()
876 if (!dev->has_crop_cap) in vivid_vid_cap_g_selection()
877 return -EINVAL; in vivid_vid_cap_g_selection()
878 sel->r = dev->crop_cap; in vivid_vid_cap_g_selection()
882 if (!dev->has_crop_cap) in vivid_vid_cap_g_selection()
883 return -EINVAL; in vivid_vid_cap_g_selection()
884 sel->r = dev->src_rect; in vivid_vid_cap_g_selection()
887 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
888 return -EINVAL; in vivid_vid_cap_g_selection()
889 sel->r = vivid_max_rect; in vivid_vid_cap_g_selection()
892 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
893 return -EINVAL; in vivid_vid_cap_g_selection()
894 sel->r = dev->compose_cap; in vivid_vid_cap_g_selection()
897 if (!dev->has_compose_cap) in vivid_vid_cap_g_selection()
898 return -EINVAL; in vivid_vid_cap_g_selection()
899 sel->r = dev->fmt_cap_rect; in vivid_vid_cap_g_selection()
902 return -EINVAL; in vivid_vid_cap_g_selection()
910 struct v4l2_rect *crop = &dev->crop_cap; in vivid_vid_cap_s_selection()
911 struct v4l2_rect *compose = &dev->compose_cap; in vivid_vid_cap_s_selection()
912 unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_cap) ? 2 : 1; in vivid_vid_cap_s_selection()
915 if (!dev->has_crop_cap && !dev->has_compose_cap) in vivid_vid_cap_s_selection()
916 return -ENOTTY; in vivid_vid_cap_s_selection()
917 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vivid_vid_cap_s_selection()
918 return -EINVAL; in vivid_vid_cap_s_selection()
920 return -ENODATA; in vivid_vid_cap_s_selection()
922 switch (s->target) { in vivid_vid_cap_s_selection()
924 if (!dev->has_crop_cap) in vivid_vid_cap_s_selection()
925 return -EINVAL; in vivid_vid_cap_s_selection()
926 ret = vivid_vid_adjust_sel(s->flags, &s->r); in vivid_vid_cap_s_selection()
929 v4l2_rect_set_min_size(&s->r, &vivid_min_rect); in vivid_vid_cap_s_selection()
930 v4l2_rect_set_max_size(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
931 v4l2_rect_map_inside(&s->r, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
932 s->r.top /= factor; in vivid_vid_cap_s_selection()
933 s->r.height /= factor; in vivid_vid_cap_s_selection()
934 if (dev->has_scaler_cap) { in vivid_vid_cap_s_selection()
935 struct v4l2_rect fmt = dev->fmt_cap_rect; in vivid_vid_cap_s_selection()
938 s->r.width * MAX_ZOOM, in vivid_vid_cap_s_selection()
939 s->r.height * MAX_ZOOM in vivid_vid_cap_s_selection()
943 s->r.width / MAX_ZOOM, in vivid_vid_cap_s_selection()
944 s->r.height / MAX_ZOOM in vivid_vid_cap_s_selection()
948 if (!dev->has_compose_cap) in vivid_vid_cap_s_selection()
950 if (!v4l2_rect_same_size(&dev->fmt_cap_rect, &fmt) && in vivid_vid_cap_s_selection()
951 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
952 return -EBUSY; in vivid_vid_cap_s_selection()
953 if (dev->has_compose_cap) { in vivid_vid_cap_s_selection()
957 dev->fmt_cap_rect = fmt; in vivid_vid_cap_s_selection()
958 tpg_s_buf_height(&dev->tpg, fmt.height); in vivid_vid_cap_s_selection()
959 } else if (dev->has_compose_cap) { in vivid_vid_cap_s_selection()
960 struct v4l2_rect fmt = dev->fmt_cap_rect; in vivid_vid_cap_s_selection()
962 v4l2_rect_set_min_size(&fmt, &s->r); in vivid_vid_cap_s_selection()
963 if (!v4l2_rect_same_size(&dev->fmt_cap_rect, &fmt) && in vivid_vid_cap_s_selection()
964 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
965 return -EBUSY; in vivid_vid_cap_s_selection()
966 dev->fmt_cap_rect = fmt; in vivid_vid_cap_s_selection()
967 tpg_s_buf_height(&dev->tpg, fmt.height); in vivid_vid_cap_s_selection()
968 v4l2_rect_set_size_to(compose, &s->r); in vivid_vid_cap_s_selection()
969 v4l2_rect_map_inside(compose, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
971 if (!v4l2_rect_same_size(&s->r, &dev->fmt_cap_rect) && in vivid_vid_cap_s_selection()
972 vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_selection()
973 return -EBUSY; in vivid_vid_cap_s_selection()
974 v4l2_rect_set_size_to(&dev->fmt_cap_rect, &s->r); in vivid_vid_cap_s_selection()
975 v4l2_rect_set_size_to(compose, &s->r); in vivid_vid_cap_s_selection()
976 v4l2_rect_map_inside(compose, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
977 tpg_s_buf_height(&dev->tpg, dev->fmt_cap_rect.height); in vivid_vid_cap_s_selection()
979 s->r.top *= factor; in vivid_vid_cap_s_selection()
980 s->r.height *= factor; in vivid_vid_cap_s_selection()
981 *crop = s->r; in vivid_vid_cap_s_selection()
984 if (!dev->has_compose_cap) in vivid_vid_cap_s_selection()
985 return -EINVAL; in vivid_vid_cap_s_selection()
986 ret = vivid_vid_adjust_sel(s->flags, &s->r); in vivid_vid_cap_s_selection()
989 v4l2_rect_set_min_size(&s->r, &vivid_min_rect); in vivid_vid_cap_s_selection()
990 v4l2_rect_set_max_size(&s->r, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
991 if (dev->has_scaler_cap) { in vivid_vid_cap_s_selection()
994 dev->src_rect.width * MAX_ZOOM, in vivid_vid_cap_s_selection()
995 (dev->src_rect.height / factor) * MAX_ZOOM in vivid_vid_cap_s_selection()
998 v4l2_rect_set_max_size(&s->r, &max_rect); in vivid_vid_cap_s_selection()
999 if (dev->has_crop_cap) { in vivid_vid_cap_s_selection()
1002 s->r.width / MAX_ZOOM, in vivid_vid_cap_s_selection()
1003 (s->r.height * factor) / MAX_ZOOM in vivid_vid_cap_s_selection()
1007 s->r.width * MAX_ZOOM, in vivid_vid_cap_s_selection()
1008 (s->r.height * factor) * MAX_ZOOM in vivid_vid_cap_s_selection()
1013 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
1015 } else if (dev->has_crop_cap) { in vivid_vid_cap_s_selection()
1016 s->r.top *= factor; in vivid_vid_cap_s_selection()
1017 s->r.height *= factor; in vivid_vid_cap_s_selection()
1018 v4l2_rect_set_max_size(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
1019 v4l2_rect_set_size_to(crop, &s->r); in vivid_vid_cap_s_selection()
1020 v4l2_rect_map_inside(crop, &dev->crop_bounds_cap); in vivid_vid_cap_s_selection()
1021 s->r.top /= factor; in vivid_vid_cap_s_selection()
1022 s->r.height /= factor; in vivid_vid_cap_s_selection()
1024 v4l2_rect_set_size_to(&s->r, &dev->src_rect); in vivid_vid_cap_s_selection()
1025 s->r.height /= factor; in vivid_vid_cap_s_selection()
1027 v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect); in vivid_vid_cap_s_selection()
1028 if (dev->bitmap_cap && (compose->width != s->r.width || in vivid_vid_cap_s_selection()
1029 compose->height != s->r.height)) { in vivid_vid_cap_s_selection()
1030 vfree(dev->bitmap_cap); in vivid_vid_cap_s_selection()
1031 dev->bitmap_cap = NULL; in vivid_vid_cap_s_selection()
1033 *compose = s->r; in vivid_vid_cap_s_selection()
1036 return -EINVAL; in vivid_vid_cap_s_selection()
1039 tpg_s_crop_compose(&dev->tpg, crop, compose); in vivid_vid_cap_s_selection()
1049 return -EINVAL; in vivid_vid_cap_g_pixelaspect()
1053 f->numerator = 11; in vivid_vid_cap_g_pixelaspect()
1054 f->denominator = 10; in vivid_vid_cap_g_pixelaspect()
1057 f->numerator = 54; in vivid_vid_cap_g_pixelaspect()
1058 f->denominator = 59; in vivid_vid_cap_g_pixelaspect()
1072 if (dev->multiplanar) in vidioc_enum_fmt_vid_overlay()
1073 return -ENOTTY; in vidioc_enum_fmt_vid_overlay()
1075 if (f->index >= ARRAY_SIZE(formats_ovl)) in vidioc_enum_fmt_vid_overlay()
1076 return -EINVAL; in vidioc_enum_fmt_vid_overlay()
1078 fmt = &formats_ovl[f->index]; in vidioc_enum_fmt_vid_overlay()
1080 f->pixelformat = fmt->fourcc; in vidioc_enum_fmt_vid_overlay()
1088 const struct v4l2_rect *compose = &dev->compose_cap; in vidioc_g_fmt_vid_overlay()
1089 struct v4l2_window *win = &f->fmt.win; in vidioc_g_fmt_vid_overlay()
1090 unsigned clipcount = win->clipcount; in vidioc_g_fmt_vid_overlay()
1092 if (dev->multiplanar) in vidioc_g_fmt_vid_overlay()
1093 return -ENOTTY; in vidioc_g_fmt_vid_overlay()
1095 win->w.top = dev->overlay_cap_top; in vidioc_g_fmt_vid_overlay()
1096 win->w.left = dev->overlay_cap_left; in vidioc_g_fmt_vid_overlay()
1097 win->w.width = compose->width; in vidioc_g_fmt_vid_overlay()
1098 win->w.height = compose->height; in vidioc_g_fmt_vid_overlay()
1099 win->field = dev->overlay_cap_field; in vidioc_g_fmt_vid_overlay()
1100 win->clipcount = dev->clipcount_cap; in vidioc_g_fmt_vid_overlay()
1101 if (clipcount > dev->clipcount_cap) in vidioc_g_fmt_vid_overlay()
1102 clipcount = dev->clipcount_cap; in vidioc_g_fmt_vid_overlay()
1103 if (dev->bitmap_cap == NULL) in vidioc_g_fmt_vid_overlay()
1104 win->bitmap = NULL; in vidioc_g_fmt_vid_overlay()
1105 else if (win->bitmap) { in vidioc_g_fmt_vid_overlay()
1106 if (copy_to_user(win->bitmap, dev->bitmap_cap, in vidioc_g_fmt_vid_overlay()
1107 ((compose->width + 7) / 8) * compose->height)) in vidioc_g_fmt_vid_overlay()
1108 return -EFAULT; in vidioc_g_fmt_vid_overlay()
1110 if (clipcount && win->clips) { in vidioc_g_fmt_vid_overlay()
1111 if (copy_to_user(win->clips, dev->clips_cap, in vidioc_g_fmt_vid_overlay()
1112 clipcount * sizeof(dev->clips_cap[0]))) in vidioc_g_fmt_vid_overlay()
1113 return -EFAULT; in vidioc_g_fmt_vid_overlay()
1122 const struct v4l2_rect *compose = &dev->compose_cap; in vidioc_try_fmt_vid_overlay()
1123 struct v4l2_window *win = &f->fmt.win; in vidioc_try_fmt_vid_overlay()
1126 if (dev->multiplanar) in vidioc_try_fmt_vid_overlay()
1127 return -ENOTTY; in vidioc_try_fmt_vid_overlay()
1129 win->w.left = clamp_t(int, win->w.left, in vidioc_try_fmt_vid_overlay()
1130 -dev->fb_cap.fmt.width, dev->fb_cap.fmt.width); in vidioc_try_fmt_vid_overlay()
1131 win->w.top = clamp_t(int, win->w.top, in vidioc_try_fmt_vid_overlay()
1132 -dev->fb_cap.fmt.height, dev->fb_cap.fmt.height); in vidioc_try_fmt_vid_overlay()
1133 win->w.width = compose->width; in vidioc_try_fmt_vid_overlay()
1134 win->w.height = compose->height; in vidioc_try_fmt_vid_overlay()
1135 if (win->field != V4L2_FIELD_BOTTOM && win->field != V4L2_FIELD_TOP) in vidioc_try_fmt_vid_overlay()
1136 win->field = V4L2_FIELD_ANY; in vidioc_try_fmt_vid_overlay()
1137 win->chromakey = 0; in vidioc_try_fmt_vid_overlay()
1138 win->global_alpha = 0; in vidioc_try_fmt_vid_overlay()
1139 if (win->clipcount && !win->clips) in vidioc_try_fmt_vid_overlay()
1140 win->clipcount = 0; in vidioc_try_fmt_vid_overlay()
1141 if (win->clipcount > MAX_CLIPS) in vidioc_try_fmt_vid_overlay()
1142 win->clipcount = MAX_CLIPS; in vidioc_try_fmt_vid_overlay()
1143 if (win->clipcount) { in vidioc_try_fmt_vid_overlay()
1144 if (copy_from_user(dev->try_clips_cap, win->clips, in vidioc_try_fmt_vid_overlay()
1145 win->clipcount * sizeof(dev->clips_cap[0]))) in vidioc_try_fmt_vid_overlay()
1146 return -EFAULT; in vidioc_try_fmt_vid_overlay()
1147 for (i = 0; i < win->clipcount; i++) { in vidioc_try_fmt_vid_overlay()
1148 struct v4l2_rect *r = &dev->try_clips_cap[i].c; in vidioc_try_fmt_vid_overlay()
1150 r->top = clamp_t(s32, r->top, 0, dev->fb_cap.fmt.height - 1); in vidioc_try_fmt_vid_overlay()
1151 r->height = clamp_t(s32, r->height, 1, dev->fb_cap.fmt.height - r->top); in vidioc_try_fmt_vid_overlay()
1152 r->left = clamp_t(u32, r->left, 0, dev->fb_cap.fmt.width - 1); in vidioc_try_fmt_vid_overlay()
1153 r->width = clamp_t(u32, r->width, 1, dev->fb_cap.fmt.width - r->left); in vidioc_try_fmt_vid_overlay()
1157 * number and it's typically a one-time deal. in vidioc_try_fmt_vid_overlay()
1159 for (i = 0; i < win->clipcount - 1; i++) { in vidioc_try_fmt_vid_overlay()
1160 struct v4l2_rect *r1 = &dev->try_clips_cap[i].c; in vidioc_try_fmt_vid_overlay()
1162 for (j = i + 1; j < win->clipcount; j++) { in vidioc_try_fmt_vid_overlay()
1163 struct v4l2_rect *r2 = &dev->try_clips_cap[j].c; in vidioc_try_fmt_vid_overlay()
1166 return -EINVAL; in vidioc_try_fmt_vid_overlay()
1169 if (copy_to_user(win->clips, dev->try_clips_cap, in vidioc_try_fmt_vid_overlay()
1170 win->clipcount * sizeof(dev->clips_cap[0]))) in vidioc_try_fmt_vid_overlay()
1171 return -EFAULT; in vidioc_try_fmt_vid_overlay()
1180 const struct v4l2_rect *compose = &dev->compose_cap; in vidioc_s_fmt_vid_overlay()
1181 struct v4l2_window *win = &f->fmt.win; in vidioc_s_fmt_vid_overlay()
1183 unsigned bitmap_size = ((compose->width + 7) / 8) * compose->height; in vidioc_s_fmt_vid_overlay()
1184 unsigned clips_size = win->clipcount * sizeof(dev->clips_cap[0]); in vidioc_s_fmt_vid_overlay()
1190 if (win->bitmap) { in vidioc_s_fmt_vid_overlay()
1194 return -ENOMEM; in vidioc_s_fmt_vid_overlay()
1195 if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) { in vidioc_s_fmt_vid_overlay()
1197 return -EFAULT; in vidioc_s_fmt_vid_overlay()
1201 dev->overlay_cap_top = win->w.top; in vidioc_s_fmt_vid_overlay()
1202 dev->overlay_cap_left = win->w.left; in vidioc_s_fmt_vid_overlay()
1203 dev->overlay_cap_field = win->field; in vidioc_s_fmt_vid_overlay()
1204 vfree(dev->bitmap_cap); in vidioc_s_fmt_vid_overlay()
1205 dev->bitmap_cap = new_bitmap; in vidioc_s_fmt_vid_overlay()
1206 dev->clipcount_cap = win->clipcount; in vidioc_s_fmt_vid_overlay()
1207 if (dev->clipcount_cap) in vidioc_s_fmt_vid_overlay()
1208 memcpy(dev->clips_cap, dev->try_clips_cap, clips_size); in vidioc_s_fmt_vid_overlay()
1216 if (dev->multiplanar) in vivid_vid_cap_overlay()
1217 return -ENOTTY; in vivid_vid_cap_overlay()
1219 if (i && dev->fb_vbase_cap == NULL) in vivid_vid_cap_overlay()
1220 return -EINVAL; in vivid_vid_cap_overlay()
1222 if (i && dev->fb_cap.fmt.pixelformat != dev->fmt_cap->fourcc) { in vivid_vid_cap_overlay()
1224 return -EINVAL; in vivid_vid_cap_overlay()
1227 if (dev->overlay_cap_owner && dev->overlay_cap_owner != fh) in vivid_vid_cap_overlay()
1228 return -EBUSY; in vivid_vid_cap_overlay()
1229 dev->overlay_cap_owner = i ? fh : NULL; in vivid_vid_cap_overlay()
1238 if (dev->multiplanar) in vivid_vid_cap_g_fbuf()
1239 return -ENOTTY; in vivid_vid_cap_g_fbuf()
1241 *a = dev->fb_cap; in vivid_vid_cap_g_fbuf()
1242 a->capability = V4L2_FBUF_CAP_BITMAP_CLIPPING | in vivid_vid_cap_g_fbuf()
1244 a->flags = V4L2_FBUF_FLAG_PRIMARY; in vivid_vid_cap_g_fbuf()
1245 a->fmt.field = V4L2_FIELD_NONE; in vivid_vid_cap_g_fbuf()
1246 a->fmt.colorspace = V4L2_COLORSPACE_SRGB; in vivid_vid_cap_g_fbuf()
1247 a->fmt.priv = 0; in vivid_vid_cap_g_fbuf()
1257 if (dev->multiplanar) in vivid_vid_cap_s_fbuf()
1258 return -ENOTTY; in vivid_vid_cap_s_fbuf()
1261 return -EPERM; in vivid_vid_cap_s_fbuf()
1263 if (dev->overlay_cap_owner) in vivid_vid_cap_s_fbuf()
1264 return -EBUSY; in vivid_vid_cap_s_fbuf()
1266 if (a->base == NULL) { in vivid_vid_cap_s_fbuf()
1267 dev->fb_cap.base = NULL; in vivid_vid_cap_s_fbuf()
1268 dev->fb_vbase_cap = NULL; in vivid_vid_cap_s_fbuf()
1272 if (a->fmt.width < 48 || a->fmt.height < 32) in vivid_vid_cap_s_fbuf()
1273 return -EINVAL; in vivid_vid_cap_s_fbuf()
1274 fmt = vivid_get_format(dev, a->fmt.pixelformat); in vivid_vid_cap_s_fbuf()
1275 if (!fmt || !fmt->can_do_overlay) in vivid_vid_cap_s_fbuf()
1276 return -EINVAL; in vivid_vid_cap_s_fbuf()
1277 if (a->fmt.bytesperline < (a->fmt.width * fmt->bit_depth[0]) / 8) in vivid_vid_cap_s_fbuf()
1278 return -EINVAL; in vivid_vid_cap_s_fbuf()
1279 if (a->fmt.height * a->fmt.bytesperline < a->fmt.sizeimage) in vivid_vid_cap_s_fbuf()
1280 return -EINVAL; in vivid_vid_cap_s_fbuf()
1282 dev->fb_vbase_cap = phys_to_virt((unsigned long)a->base); in vivid_vid_cap_s_fbuf()
1283 dev->fb_cap = *a; in vivid_vid_cap_s_fbuf()
1284 dev->overlay_cap_left = clamp_t(int, dev->overlay_cap_left, in vivid_vid_cap_s_fbuf()
1285 -dev->fb_cap.fmt.width, dev->fb_cap.fmt.width); in vivid_vid_cap_s_fbuf()
1286 dev->overlay_cap_top = clamp_t(int, dev->overlay_cap_top, in vivid_vid_cap_s_fbuf()
1287 -dev->fb_cap.fmt.height, dev->fb_cap.fmt.height); in vivid_vid_cap_s_fbuf()
1293 { 1, "Line-In", V4L2_AUDCAP_STEREO },
1301 if (inp->index >= dev->num_inputs) in vidioc_enum_input()
1302 return -EINVAL; in vidioc_enum_input()
1304 inp->type = V4L2_INPUT_TYPE_CAMERA; in vidioc_enum_input()
1305 switch (dev->input_type[inp->index]) { in vidioc_enum_input()
1307 snprintf(inp->name, sizeof(inp->name), "Webcam %u", in vidioc_enum_input()
1308 dev->input_name_counter[inp->index]); in vidioc_enum_input()
1309 inp->capabilities = 0; in vidioc_enum_input()
1312 snprintf(inp->name, sizeof(inp->name), "TV %u", in vidioc_enum_input()
1313 dev->input_name_counter[inp->index]); in vidioc_enum_input()
1314 inp->type = V4L2_INPUT_TYPE_TUNER; in vidioc_enum_input()
1315 inp->std = V4L2_STD_ALL; in vidioc_enum_input()
1316 if (dev->has_audio_inputs) in vidioc_enum_input()
1317 inp->audioset = (1 << ARRAY_SIZE(vivid_audio_inputs)) - 1; in vidioc_enum_input()
1318 inp->capabilities = V4L2_IN_CAP_STD; in vidioc_enum_input()
1321 snprintf(inp->name, sizeof(inp->name), "S-Video %u", in vidioc_enum_input()
1322 dev->input_name_counter[inp->index]); in vidioc_enum_input()
1323 inp->std = V4L2_STD_ALL; in vidioc_enum_input()
1324 if (dev->has_audio_inputs) in vidioc_enum_input()
1325 inp->audioset = (1 << ARRAY_SIZE(vivid_audio_inputs)) - 1; in vidioc_enum_input()
1326 inp->capabilities = V4L2_IN_CAP_STD; in vidioc_enum_input()
1329 snprintf(inp->name, sizeof(inp->name), "HDMI %u", in vidioc_enum_input()
1330 dev->input_name_counter[inp->index]); in vidioc_enum_input()
1331 inp->capabilities = V4L2_IN_CAP_DV_TIMINGS; in vidioc_enum_input()
1332 if (dev->edid_blocks == 0 || in vidioc_enum_input()
1333 dev->dv_timings_signal_mode[dev->input] == NO_SIGNAL) in vidioc_enum_input()
1334 inp->status |= V4L2_IN_ST_NO_SIGNAL; in vidioc_enum_input()
1335 else if (dev->dv_timings_signal_mode[dev->input] == NO_LOCK || in vidioc_enum_input()
1336 dev->dv_timings_signal_mode[dev->input] == OUT_OF_RANGE) in vidioc_enum_input()
1337 inp->status |= V4L2_IN_ST_NO_H_LOCK; in vidioc_enum_input()
1340 if (dev->sensor_hflip) in vidioc_enum_input()
1341 inp->status |= V4L2_IN_ST_HFLIP; in vidioc_enum_input()
1342 if (dev->sensor_vflip) in vidioc_enum_input()
1343 inp->status |= V4L2_IN_ST_VFLIP; in vidioc_enum_input()
1344 if (dev->input == inp->index && vivid_is_sdtv_cap(dev)) { in vidioc_enum_input()
1345 if (dev->std_signal_mode[dev->input] == NO_SIGNAL) { in vidioc_enum_input()
1346 inp->status |= V4L2_IN_ST_NO_SIGNAL; in vidioc_enum_input()
1347 } else if (dev->std_signal_mode[dev->input] == NO_LOCK) { in vidioc_enum_input()
1348 inp->status |= V4L2_IN_ST_NO_H_LOCK; in vidioc_enum_input()
1350 switch (tpg_g_quality(&dev->tpg)) { in vidioc_enum_input()
1352 inp->status |= V4L2_IN_ST_COLOR_KILL; in vidioc_enum_input()
1355 inp->status |= V4L2_IN_ST_NO_H_LOCK; in vidioc_enum_input()
1369 *i = dev->input; in vidioc_g_input()
1376 struct v4l2_bt_timings *bt = &dev->dv_timings_cap[dev->input].bt; in vidioc_s_input()
1379 if (i >= dev->num_inputs) in vidioc_s_input()
1380 return -EINVAL; in vidioc_s_input()
1382 if (i == dev->input) in vidioc_s_input()
1385 if (vb2_is_busy(&dev->vb_vid_cap_q) || in vidioc_s_input()
1386 vb2_is_busy(&dev->vb_vbi_cap_q) || in vidioc_s_input()
1387 vb2_is_busy(&dev->vb_meta_cap_q)) in vidioc_s_input()
1388 return -EBUSY; in vidioc_s_input()
1390 dev->input = i; in vidioc_s_input()
1391 dev->vid_cap_dev.tvnorms = 0; in vidioc_s_input()
1392 if (dev->input_type[i] == TV || dev->input_type[i] == SVID) { in vidioc_s_input()
1393 dev->tv_audio_input = (dev->input_type[i] == TV) ? 0 : 1; in vidioc_s_input()
1394 dev->vid_cap_dev.tvnorms = V4L2_STD_ALL; in vidioc_s_input()
1396 dev->vbi_cap_dev.tvnorms = dev->vid_cap_dev.tvnorms; in vidioc_s_input()
1397 dev->meta_cap_dev.tvnorms = dev->vid_cap_dev.tvnorms; in vidioc_s_input()
1400 if (dev->colorspace) { in vidioc_s_input()
1401 switch (dev->input_type[i]) { in vidioc_s_input()
1403 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vidioc_s_input()
1407 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vidioc_s_input()
1410 if (bt->flags & V4L2_DV_FL_IS_CE_VIDEO) { in vidioc_s_input()
1411 if (dev->src_rect.width == 720 && dev->src_rect.height <= 576) in vidioc_s_input()
1412 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); in vidioc_s_input()
1414 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); in vidioc_s_input()
1416 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); in vidioc_s_input()
1429 brightness = 128 * i + dev->input_brightness[i]; in vidioc_s_input()
1430 v4l2_ctrl_modify_range(dev->brightness, in vidioc_s_input()
1432 v4l2_ctrl_s_ctrl(dev->brightness, brightness); in vidioc_s_input()
1434 /* Restore per-input states. */ in vidioc_s_input()
1435 v4l2_ctrl_activate(dev->ctrl_dv_timings_signal_mode, in vidioc_s_input()
1437 v4l2_ctrl_activate(dev->ctrl_dv_timings, vivid_is_hdmi_cap(dev) && in vidioc_s_input()
1438 dev->dv_timings_signal_mode[dev->input] == in vidioc_s_input()
1440 v4l2_ctrl_activate(dev->ctrl_std_signal_mode, vivid_is_sdtv_cap(dev)); in vidioc_s_input()
1441 v4l2_ctrl_activate(dev->ctrl_standard, vivid_is_sdtv_cap(dev) && in vidioc_s_input()
1442 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1445 v4l2_ctrl_s_ctrl(dev->ctrl_dv_timings_signal_mode, in vidioc_s_input()
1446 dev->dv_timings_signal_mode[dev->input]); in vidioc_s_input()
1447 v4l2_ctrl_s_ctrl(dev->ctrl_dv_timings, in vidioc_s_input()
1448 dev->query_dv_timings[dev->input]); in vidioc_s_input()
1450 v4l2_ctrl_s_ctrl(dev->ctrl_std_signal_mode, in vidioc_s_input()
1451 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1452 v4l2_ctrl_s_ctrl(dev->ctrl_standard, in vidioc_s_input()
1453 dev->std_signal_mode[dev->input]); in vidioc_s_input()
1461 if (vin->index >= ARRAY_SIZE(vivid_audio_inputs)) in vidioc_enumaudio()
1462 return -EINVAL; in vidioc_enumaudio()
1463 *vin = vivid_audio_inputs[vin->index]; in vidioc_enumaudio()
1472 return -EINVAL; in vidioc_g_audio()
1473 *vin = vivid_audio_inputs[dev->tv_audio_input]; in vidioc_g_audio()
1482 return -EINVAL; in vidioc_s_audio()
1483 if (vin->index >= ARRAY_SIZE(vivid_audio_inputs)) in vidioc_s_audio()
1484 return -EINVAL; in vidioc_s_audio()
1485 dev->tv_audio_input = vin->index; in vidioc_s_audio()
1493 if (vf->tuner != 0) in vivid_video_g_frequency()
1494 return -EINVAL; in vivid_video_g_frequency()
1495 vf->frequency = dev->tv_freq; in vivid_video_g_frequency()
1503 if (vf->tuner != 0) in vivid_video_s_frequency()
1504 return -EINVAL; in vivid_video_s_frequency()
1505 dev->tv_freq = clamp_t(unsigned, vf->frequency, MIN_TV_FREQ, MAX_TV_FREQ); in vivid_video_s_frequency()
1511 int vivid_video_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt) in vivid_video_s_tuner() argument
1515 if (vt->index != 0) in vivid_video_s_tuner()
1516 return -EINVAL; in vivid_video_s_tuner()
1517 if (vt->audmode > V4L2_TUNER_MODE_LANG1_LANG2) in vivid_video_s_tuner()
1518 return -EINVAL; in vivid_video_s_tuner()
1519 dev->tv_audmode = vt->audmode; in vivid_video_s_tuner()
1523 int vivid_video_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) in vivid_video_g_tuner() argument
1528 if (vt->index != 0) in vivid_video_g_tuner()
1529 return -EINVAL; in vivid_video_g_tuner()
1531 vt->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | in vivid_video_g_tuner()
1533 vt->audmode = dev->tv_audmode; in vivid_video_g_tuner()
1534 vt->rangelow = MIN_TV_FREQ; in vivid_video_g_tuner()
1535 vt->rangehigh = MAX_TV_FREQ; in vivid_video_g_tuner()
1536 qual = vivid_get_quality(dev, &vt->afc); in vivid_video_g_tuner()
1538 vt->signal = 0xffff; in vivid_video_g_tuner()
1540 vt->signal = 0x8000; in vivid_video_g_tuner()
1542 vt->signal = 0; in vivid_video_g_tuner()
1544 vt->rxsubchans = 0; in vivid_video_g_tuner()
1546 vt->rxsubchans = V4L2_TUNER_SUB_MONO; in vivid_video_g_tuner()
1548 unsigned int channel_nr = dev->tv_freq / (6 * 16); in vivid_video_g_tuner()
1550 (dev->std_cap[dev->input] & V4L2_STD_NTSC_M) ? 4 : 3; in vivid_video_g_tuner()
1554 vt->rxsubchans = V4L2_TUNER_SUB_MONO; in vivid_video_g_tuner()
1557 vt->rxsubchans = V4L2_TUNER_SUB_STEREO; in vivid_video_g_tuner()
1560 if (dev->std_cap[dev->input] & V4L2_STD_NTSC_M) in vivid_video_g_tuner()
1561 vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_SAP; in vivid_video_g_tuner()
1563 vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; in vivid_video_g_tuner()
1566 vt->rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_SAP; in vivid_video_g_tuner()
1570 strscpy(vt->name, "TV Tuner", sizeof(vt->name)); in vivid_video_g_tuner()
1596 "NTSC-M",
1597 "NTSC-M-JP",
1598 "NTSC-M-KR",
1599 "NTSC-443",
1600 "PAL-BGH",
1601 "PAL-I",
1602 "PAL-DK",
1603 "PAL-M",
1604 "PAL-N",
1605 "PAL-Nc",
1606 "PAL-60",
1607 "SECAM-BGH",
1608 "SECAM-DK",
1609 "SECAM-L",
1610 "SECAM-Lc",
1617 unsigned int last = dev->query_std_last[dev->input]; in vidioc_querystd()
1620 return -ENODATA; in vidioc_querystd()
1621 if (dev->std_signal_mode[dev->input] == NO_SIGNAL || in vidioc_querystd()
1622 dev->std_signal_mode[dev->input] == NO_LOCK) { in vidioc_querystd()
1626 if (vivid_is_tv_cap(dev) && tpg_g_quality(&dev->tpg) == TPG_QUAL_NOISE) { in vidioc_querystd()
1628 } else if (dev->std_signal_mode[dev->input] == CURRENT_STD) { in vidioc_querystd()
1629 *id = dev->std_cap[dev->input]; in vidioc_querystd()
1630 } else if (dev->std_signal_mode[dev->input] == SELECTED_STD) { in vidioc_querystd()
1631 *id = dev->query_std[dev->input]; in vidioc_querystd()
1634 dev->query_std_last[dev->input] = in vidioc_querystd()
1646 return -ENODATA; in vivid_vid_cap_s_std()
1647 if (dev->std_cap[dev->input] == id) in vivid_vid_cap_s_std()
1649 if (vb2_is_busy(&dev->vb_vid_cap_q) || vb2_is_busy(&dev->vb_vbi_cap_q)) in vivid_vid_cap_s_std()
1650 return -EBUSY; in vivid_vid_cap_s_std()
1651 dev->std_cap[dev->input] = id; in vivid_vid_cap_s_std()
1682 struct v4l2_bt_timings *bt = &timings->bt; in valid_cvt_gtf_timings()
1694 h_freq = (u32)bt->pixelclock / total_h_pixel; in valid_cvt_gtf_timings()
1696 if (bt->standards == 0 || (bt->standards & V4L2_DV_BT_STD_CVT)) { in valid_cvt_gtf_timings()
1697 if (v4l2_detect_cvt(total_v_lines, h_freq, bt->vsync, bt->width, in valid_cvt_gtf_timings()
1698 bt->polarities, bt->interlaced, timings)) in valid_cvt_gtf_timings()
1702 if (bt->standards == 0 || (bt->standards & V4L2_DV_BT_STD_GTF)) { in valid_cvt_gtf_timings()
1705 find_aspect_ratio(bt->width, bt->height, in valid_cvt_gtf_timings()
1708 if (v4l2_detect_gtf(total_v_lines, h_freq, bt->vsync, in valid_cvt_gtf_timings()
1709 bt->polarities, bt->interlaced, in valid_cvt_gtf_timings()
1722 return -ENODATA; in vivid_vid_cap_s_dv_timings()
1726 return -EINVAL; in vivid_vid_cap_s_dv_timings()
1728 if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap[dev->input], in vivid_vid_cap_s_dv_timings()
1731 if (vb2_is_busy(&dev->vb_vid_cap_q)) in vivid_vid_cap_s_dv_timings()
1732 return -EBUSY; in vivid_vid_cap_s_dv_timings()
1734 dev->dv_timings_cap[dev->input] = *timings; in vivid_vid_cap_s_dv_timings()
1743 unsigned int input = dev->input; in vidioc_query_dv_timings()
1744 unsigned int last = dev->query_dv_timings_last[input]; in vidioc_query_dv_timings()
1747 return -ENODATA; in vidioc_query_dv_timings()
1748 if (dev->dv_timings_signal_mode[input] == NO_SIGNAL || in vidioc_query_dv_timings()
1749 dev->edid_blocks == 0) in vidioc_query_dv_timings()
1750 return -ENOLINK; in vidioc_query_dv_timings()
1751 if (dev->dv_timings_signal_mode[input] == NO_LOCK) in vidioc_query_dv_timings()
1752 return -ENOLCK; in vidioc_query_dv_timings()
1753 if (dev->dv_timings_signal_mode[input] == OUT_OF_RANGE) { in vidioc_query_dv_timings()
1754 timings->bt.pixelclock = vivid_dv_timings_cap.bt.max_pixelclock * 2; in vidioc_query_dv_timings()
1755 return -ERANGE; in vidioc_query_dv_timings()
1757 if (dev->dv_timings_signal_mode[input] == CURRENT_DV_TIMINGS) { in vidioc_query_dv_timings()
1758 *timings = dev->dv_timings_cap[input]; in vidioc_query_dv_timings()
1759 } else if (dev->dv_timings_signal_mode[input] == in vidioc_query_dv_timings()
1762 v4l2_dv_timings_presets[dev->query_dv_timings[input]]; in vidioc_query_dv_timings()
1766 dev->query_dv_timings_last[input] = in vidioc_query_dv_timings()
1767 (last + 1) % dev->query_dv_timings_size; in vidioc_query_dv_timings()
1781 memset(edid->reserved, 0, sizeof(edid->reserved)); in vidioc_s_edid()
1782 if (edid->pad >= dev->num_inputs) in vidioc_s_edid()
1783 return -EINVAL; in vidioc_s_edid()
1784 if (dev->input_type[edid->pad] != HDMI || edid->start_block) in vidioc_s_edid()
1785 return -EINVAL; in vidioc_s_edid()
1786 if (edid->blocks == 0) { in vidioc_s_edid()
1787 dev->edid_blocks = 0; in vidioc_s_edid()
1788 v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, 0); in vidioc_s_edid()
1789 v4l2_ctrl_s_ctrl(dev->ctrl_tx_hotplug, 0); in vidioc_s_edid()
1793 if (edid->blocks > dev->edid_max_blocks) { in vidioc_s_edid()
1794 edid->blocks = dev->edid_max_blocks; in vidioc_s_edid()
1795 return -E2BIG; in vidioc_s_edid()
1797 phys_addr = cec_get_edid_phys_addr(edid->edid, edid->blocks * 128, NULL); in vidioc_s_edid()
1802 if (vb2_is_busy(&dev->vb_vid_cap_q)) in vidioc_s_edid()
1803 return -EBUSY; in vidioc_s_edid()
1805 dev->edid_blocks = edid->blocks; in vidioc_s_edid()
1806 memcpy(dev->edid, edid->edid, edid->blocks * 128); in vidioc_s_edid()
1808 for (i = 0, j = 0; i < dev->num_outputs; i++) in vidioc_s_edid()
1809 if (dev->output_type[i] == HDMI) in vidioc_s_edid()
1811 dev->display_present[i] << j++; in vidioc_s_edid()
1813 v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, display_present); in vidioc_s_edid()
1814 v4l2_ctrl_s_ctrl(dev->ctrl_tx_hotplug, display_present); in vidioc_s_edid()
1818 cec_s_phys_addr(dev->cec_rx_adap, phys_addr, false); in vidioc_s_edid()
1820 for (i = 0; i < MAX_OUTPUTS && dev->cec_tx_adap[i]; i++) in vidioc_s_edid()
1821 cec_s_phys_addr(dev->cec_tx_adap[i], in vidioc_s_edid()
1822 dev->display_present[i] ? in vidioc_s_edid()
1834 if (!vivid_is_webcam(dev) && !dev->has_scaler_cap) in vidioc_enum_framesizes()
1835 return -EINVAL; in vidioc_enum_framesizes()
1836 if (vivid_get_format(dev, fsize->pixel_format) == NULL) in vidioc_enum_framesizes()
1837 return -EINVAL; in vidioc_enum_framesizes()
1839 if (fsize->index >= ARRAY_SIZE(webcam_sizes)) in vidioc_enum_framesizes()
1840 return -EINVAL; in vidioc_enum_framesizes()
1841 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; in vidioc_enum_framesizes()
1842 fsize->discrete = webcam_sizes[fsize->index]; in vidioc_enum_framesizes()
1845 if (fsize->index) in vidioc_enum_framesizes()
1846 return -EINVAL; in vidioc_enum_framesizes()
1847 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; in vidioc_enum_framesizes()
1848 fsize->stepwise.min_width = MIN_WIDTH; in vidioc_enum_framesizes()
1849 fsize->stepwise.max_width = MAX_WIDTH * MAX_ZOOM; in vidioc_enum_framesizes()
1850 fsize->stepwise.step_width = 2; in vidioc_enum_framesizes()
1851 fsize->stepwise.min_height = MIN_HEIGHT; in vidioc_enum_framesizes()
1852 fsize->stepwise.max_height = MAX_HEIGHT * MAX_ZOOM; in vidioc_enum_framesizes()
1853 fsize->stepwise.step_height = 2; in vidioc_enum_framesizes()
1865 fmt = vivid_get_format(dev, fival->pixel_format); in vidioc_enum_frameintervals()
1867 return -EINVAL; in vidioc_enum_frameintervals()
1870 if (fival->index) in vidioc_enum_frameintervals()
1871 return -EINVAL; in vidioc_enum_frameintervals()
1872 if (fival->width < MIN_WIDTH || fival->width > MAX_WIDTH * MAX_ZOOM) in vidioc_enum_frameintervals()
1873 return -EINVAL; in vidioc_enum_frameintervals()
1874 if (fival->height < MIN_HEIGHT || fival->height > MAX_HEIGHT * MAX_ZOOM) in vidioc_enum_frameintervals()
1875 return -EINVAL; in vidioc_enum_frameintervals()
1876 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; in vidioc_enum_frameintervals()
1877 fival->discrete = dev->timeperframe_vid_cap; in vidioc_enum_frameintervals()
1882 if (fival->width == webcam_sizes[i].width && in vidioc_enum_frameintervals()
1883 fival->height == webcam_sizes[i].height) in vidioc_enum_frameintervals()
1886 return -EINVAL; in vidioc_enum_frameintervals()
1887 if (fival->index >= 2 * (VIVID_WEBCAM_SIZES - i)) in vidioc_enum_frameintervals()
1888 return -EINVAL; in vidioc_enum_frameintervals()
1889 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; in vidioc_enum_frameintervals()
1890 fival->discrete = webcam_intervals[fival->index]; in vidioc_enum_frameintervals()
1899 if (parm->type != (dev->multiplanar ? in vivid_vid_cap_g_parm()
1902 return -EINVAL; in vivid_vid_cap_g_parm()
1904 parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; in vivid_vid_cap_g_parm()
1905 parm->parm.capture.timeperframe = dev->timeperframe_vid_cap; in vivid_vid_cap_g_parm()
1906 parm->parm.capture.readbuffers = 1; in vivid_vid_cap_g_parm()
1914 unsigned ival_sz = 2 * (VIVID_WEBCAM_SIZES - dev->webcam_size_idx); in vivid_vid_cap_s_parm()
1918 if (parm->type != (dev->multiplanar ? in vivid_vid_cap_s_parm()
1921 return -EINVAL; in vivid_vid_cap_s_parm()
1925 tpf = parm->parm.capture.timeperframe; in vivid_vid_cap_s_parm()
1928 tpf = webcam_intervals[ival_sz - 1]; in vivid_vid_cap_s_parm()
1933 i = ival_sz - 1; in vivid_vid_cap_s_parm()
1934 dev->webcam_ival_idx = i; in vivid_vid_cap_s_parm()
1935 tpf = webcam_intervals[dev->webcam_ival_idx]; in vivid_vid_cap_s_parm()
1938 dev->cap_seq_resync = true; in vivid_vid_cap_s_parm()
1939 dev->timeperframe_vid_cap = tpf; in vivid_vid_cap_s_parm()
1940 parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; in vivid_vid_cap_s_parm()
1941 parm->parm.capture.timeperframe = tpf; in vivid_vid_cap_s_parm()
1942 parm->parm.capture.readbuffers = 1; in vivid_vid_cap_s_parm()