Lines Matching refs:dev

27 	struct vivid_dev *dev = vb2_get_drv_priv(vq);
28 const struct vivid_fmt *vfmt = dev->fmt_out;
30 unsigned h = dev->fmt_out_rect.height;
31 unsigned int size = dev->bytesperline_out[0] * h + vfmt->data_offset[0];
35 size += dev->bytesperline_out[p] * h / vfmt->vdownsampling[p] +
38 if (dev->field_out == V4L2_FIELD_ALTERNATE) {
47 if (dev->queue_setup_error) {
52 dev->queue_setup_error = false;
66 if (sizes[p] < dev->bytesperline_out[p] * h +
72 sizes[p] = p ? dev->bytesperline_out[p] * h +
81 dprintk(dev, 1, "%s: count=%d\n", __func__, *nbuffers);
83 dprintk(dev, 1, "%s: size[%u]=%u\n", __func__, p, sizes[p]);
90 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
92 dprintk(dev, 1, "%s\n", __func__);
94 if (dev->field_out != V4L2_FIELD_ALTERNATE)
95 vbuf->field = dev->field_out;
104 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
105 const struct vivid_fmt *vfmt = dev->fmt_out;
107 unsigned int h = dev->fmt_out_rect.height;
108 unsigned int size = dev->bytesperline_out[0] * h;
112 size += dev->bytesperline_out[p] * h / vfmt->vdownsampling[p];
114 dprintk(dev, 1, "%s\n", __func__);
116 if (WARN_ON(NULL == dev->fmt_out))
119 if (dev->buf_prepare_error) {
124 dev->buf_prepare_error = false;
130 size = dev->bytesperline_out[p] * h;
134 dprintk(dev, 1, "%s the payload is too small for plane %u (%lu < %u)\n",
146 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
149 dprintk(dev, 1, "%s\n", __func__);
151 spin_lock(&dev->slock);
152 list_add_tail(&buf->list, &dev->vid_out_active);
153 spin_unlock(&dev->slock);
158 struct vivid_dev *dev = vb2_get_drv_priv(vq);
161 if (vb2_is_streaming(&dev->vb_vid_cap_q))
162 dev->can_loop_video = vivid_vid_can_loop(dev);
164 dev->vid_out_seq_count = 0;
165 dprintk(dev, 1, "%s\n", __func__);
166 if (dev->start_streaming_error) {
167 dev->start_streaming_error = false;
170 err = vivid_start_generating_vid_out(dev, &dev->vid_out_streaming);
175 list_for_each_entry_safe(buf, tmp, &dev->vid_out_active, list) {
187 struct vivid_dev *dev = vb2_get_drv_priv(vq);
189 dprintk(dev, 1, "%s\n", __func__);
190 vivid_stop_generating_vid_out(dev, &dev->vid_out_streaming);
191 dev->can_loop_video = false;
196 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
198 v4l2_ctrl_request_complete(vb->req_obj.req, &dev->ctrl_hdl_vid_out);
217 void vivid_update_format_out(struct vivid_dev *dev)
219 struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
223 switch (dev->output_type[dev->output]) {
226 dev->field_out = dev->tv_field_out;
227 dev->sink_rect.width = 720;
228 if (dev->std_out & V4L2_STD_525_60) {
229 dev->sink_rect.height = 480;
230 dev->timeperframe_vid_out = (struct v4l2_fract) { 1001, 30000 };
231 dev->service_set_out = V4L2_SLICED_CAPTION_525;
233 dev->sink_rect.height = 576;
234 dev->timeperframe_vid_out = (struct v4l2_fract) { 1000, 25000 };
235 dev->service_set_out = V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B;
237 dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M;
240 dev->sink_rect.width = bt->width;
241 dev->sink_rect.height = bt->height;
249 dev->timeperframe_vid_out = (struct v4l2_fract) {
253 dev->field_out = V4L2_FIELD_ALTERNATE;
255 dev->field_out = V4L2_FIELD_NONE;
256 if (!dev->dvi_d_out && (bt->flags & V4L2_DV_FL_IS_CE_VIDEO)) {
258 dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M;
260 dev->colorspace_out = V4L2_COLORSPACE_REC709;
262 dev->colorspace_out = V4L2_COLORSPACE_SRGB;
266 dev->xfer_func_out = V4L2_XFER_FUNC_DEFAULT;
267 dev->ycbcr_enc_out = V4L2_YCBCR_ENC_DEFAULT;
268 dev->hsv_enc_out = V4L2_HSV_ENC_180;
269 dev->quantization_out = V4L2_QUANTIZATION_DEFAULT;
270 dev->compose_out = dev->sink_rect;
271 dev->compose_bounds_out = dev->sink_rect;
272 dev->crop_out = dev->compose_out;
273 if (V4L2_FIELD_HAS_T_OR_B(dev->field_out))
274 dev->crop_out.height /= 2;
275 dev->fmt_out_rect = dev->crop_out;
276 for (p = 0; p < dev->fmt_out->planes; p++)
277 dev->bytesperline_out[p] =
278 (dev->sink_rect.width * dev->fmt_out->bit_depth[p]) / 8;
282 static enum v4l2_field vivid_field_out(struct vivid_dev *dev, enum v4l2_field field)
284 if (vivid_is_svid_out(dev)) {
297 if (vivid_is_hdmi_out(dev))
298 return dev->dv_timings_out.bt.interlaced ? V4L2_FIELD_ALTERNATE :
303 static enum tpg_pixel_aspect vivid_get_pixel_aspect(const struct vivid_dev *dev)
305 if (vivid_is_svid_out(dev))
306 return (dev->std_out & V4L2_STD_525_60) ?
309 if (vivid_is_hdmi_out(dev) &&
310 dev->sink_rect.width == 720 && dev->sink_rect.height <= 576)
311 return dev->sink_rect.height == 480 ?
320 struct vivid_dev *dev = video_drvdata(file);
322 const struct vivid_fmt *fmt = dev->fmt_out;
325 mp->width = dev->fmt_out_rect.width;
326 mp->height = dev->fmt_out_rect.height;
327 mp->field = dev->field_out;
329 mp->colorspace = dev->colorspace_out;
330 mp->xfer_func = dev->xfer_func_out;
331 mp->ycbcr_enc = dev->ycbcr_enc_out;
332 mp->quantization = dev->quantization_out;
335 mp->plane_fmt[p].bytesperline = dev->bytesperline_out[p];
341 unsigned stride = dev->bytesperline_out[p];
352 struct vivid_dev *dev = video_drvdata(file);
353 struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
362 fmt = vivid_get_format(dev, mp->pixelformat);
364 dprintk(dev, 1, "Fourcc format (0x%08x) unknown.\n",
367 fmt = vivid_get_format(dev, mp->pixelformat);
370 mp->field = vivid_field_out(dev, mp->field);
371 if (vivid_is_svid_out(dev)) {
373 h = (dev->std_out & V4L2_STD_525_60) ? 480 : 576;
375 w = dev->sink_rect.width;
376 h = dev->sink_rect.height;
380 if (!dev->has_scaler_out && !dev->has_crop_out && !dev->has_compose_out) {
388 if (dev->has_scaler_out && !dev->has_crop_out) {
392 } else if (!dev->has_scaler_out && dev->has_compose_out && !dev->has_crop_out) {
393 v4l2_rect_set_max_size(&r, &dev->sink_rect);
394 } else if (!dev->has_scaler_out && !dev->has_compose_out) {
395 v4l2_rect_set_min_size(&r, &dev->sink_rect);
428 if (vivid_is_svid_out(dev)) {
430 } else if (dev->dvi_d_out || !(bt->flags & V4L2_DV_FL_IS_CE_VIDEO)) {
432 if (dev->dvi_d_out)
451 struct vivid_dev *dev = video_drvdata(file);
452 struct v4l2_rect *crop = &dev->crop_out;
453 struct v4l2_rect *compose = &dev->compose_out;
454 struct vb2_queue *q = &dev->vb_vid_out_q;
463 (vivid_is_svid_out(dev) ||
464 mp->width != dev->fmt_out_rect.width ||
465 mp->height != dev->fmt_out_rect.height ||
466 mp->pixelformat != dev->fmt_out->fourcc ||
467 mp->field != dev->field_out)) {
468 dprintk(dev, 1, "%s device busy\n", __func__);
480 dev->fmt_out = vivid_get_format(dev, mp->pixelformat);
484 if (dev->has_scaler_out || dev->has_crop_out || dev->has_compose_out) {
487 if (dev->has_scaler_out) {
488 if (dev->has_crop_out)
492 if (dev->has_compose_out && !dev->has_crop_out) {
506 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
507 } else if (dev->has_compose_out) {
521 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
523 } else if (dev->has_compose_out && !dev->has_crop_out) {
527 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
528 } else if (!dev->has_compose_out) {
535 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
551 dev->fmt_out_rect.width = mp->width;
552 dev->fmt_out_rect.height = mp->height;
554 dev->bytesperline_out[p] = mp->plane_fmt[p].bytesperline;
555 for (p = dev->fmt_out->buffers; p < dev->fmt_out->planes; p++)
556 dev->bytesperline_out[p] =
557 (dev->bytesperline_out[0] * dev->fmt_out->bit_depth[p]) /
558 dev->fmt_out->bit_depth[0];
559 dev->field_out = mp->field;
560 if (vivid_is_svid_out(dev))
561 dev->tv_field_out = mp->field;
564 dev->colorspace_out = mp->colorspace;
565 dev->xfer_func_out = mp->xfer_func;
566 dev->ycbcr_enc_out = mp->ycbcr_enc;
567 dev->quantization_out = mp->quantization;
568 if (dev->loop_video) {
569 vivid_send_source_change(dev, SVID);
570 vivid_send_source_change(dev, HDMI);
578 struct vivid_dev *dev = video_drvdata(file);
580 if (!dev->multiplanar)
588 struct vivid_dev *dev = video_drvdata(file);
590 if (!dev->multiplanar)
598 struct vivid_dev *dev = video_drvdata(file);
600 if (!dev->multiplanar)
608 struct vivid_dev *dev = video_drvdata(file);
610 if (dev->multiplanar)
618 struct vivid_dev *dev = video_drvdata(file);
620 if (dev->multiplanar)
628 struct vivid_dev *dev = video_drvdata(file);
630 if (dev->multiplanar)
638 struct vivid_dev *dev = video_drvdata(file);
640 if (!dev->has_crop_out && !dev->has_compose_out)
648 if (!dev->has_crop_out)
650 sel->r = dev->crop_out;
653 if (!dev->has_crop_out)
655 sel->r = dev->fmt_out_rect;
658 if (!dev->has_crop_out)
663 if (!dev->has_compose_out)
665 sel->r = dev->compose_out;
669 if (!dev->has_compose_out)
671 sel->r = dev->sink_rect;
681 struct vivid_dev *dev = video_drvdata(file);
682 struct v4l2_rect *crop = &dev->crop_out;
683 struct v4l2_rect *compose = &dev->compose_out;
684 unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_out) ? 2 : 1;
687 if (!dev->has_crop_out && !dev->has_compose_out)
694 if (!dev->has_crop_out)
700 v4l2_rect_set_max_size(&s->r, &dev->fmt_out_rect);
701 if (dev->has_scaler_out) {
704 dev->sink_rect.width * MAX_ZOOM,
705 (dev->sink_rect.height / factor) * MAX_ZOOM
709 if (dev->has_compose_out) {
723 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
725 } else if (dev->has_compose_out) {
728 v4l2_rect_set_max_size(&s->r, &dev->sink_rect);
730 v4l2_rect_map_inside(compose, &dev->compose_bounds_out);
734 v4l2_rect_set_size_to(&s->r, &dev->sink_rect);
737 v4l2_rect_map_inside(&s->r, &dev->fmt_out_rect);
741 if (!dev->has_compose_out)
747 v4l2_rect_set_max_size(&s->r, &dev->sink_rect);
748 v4l2_rect_map_inside(&s->r, &dev->compose_bounds_out);
751 if (dev->has_scaler_out) {
752 struct v4l2_rect fmt = dev->fmt_out_rect;
765 if (!dev->has_crop_out)
767 if (!v4l2_rect_same_size(&dev->fmt_out_rect, &fmt) &&
768 vb2_is_busy(&dev->vb_vid_out_q))
770 if (dev->has_crop_out) {
774 dev->fmt_out_rect = fmt;
775 } else if (dev->has_crop_out) {
776 struct v4l2_rect fmt = dev->fmt_out_rect;
779 if (!v4l2_rect_same_size(&dev->fmt_out_rect, &fmt) &&
780 vb2_is_busy(&dev->vb_vid_out_q))
782 dev->fmt_out_rect = fmt;
784 v4l2_rect_map_inside(crop, &dev->fmt_out_rect);
786 if (!v4l2_rect_same_size(&s->r, &dev->fmt_out_rect) &&
787 vb2_is_busy(&dev->vb_vid_out_q))
789 v4l2_rect_set_size_to(&dev->fmt_out_rect, &s->r);
792 v4l2_rect_map_inside(crop, &dev->fmt_out_rect);
808 struct vivid_dev *dev = video_drvdata(file);
813 switch (vivid_get_pixel_aspect(dev)) {
831 struct vivid_dev *dev = video_drvdata(file);
832 const struct v4l2_rect *compose = &dev->compose_out;
835 if (!dev->has_fb)
837 win->w.top = dev->overlay_out_top;
838 win->w.left = dev->overlay_out_left;
842 win->chromakey = dev->chromakey_out;
843 win->global_alpha = dev->global_alpha_out;
850 struct vivid_dev *dev = video_drvdata(file);
851 const struct v4l2_rect *compose = &dev->compose_out;
854 if (!dev->has_fb)
857 -dev->display_width, dev->display_width);
859 -dev->display_height, dev->display_height);
873 struct vivid_dev *dev = video_drvdata(file);
880 dev->overlay_out_top = win->w.top;
881 dev->overlay_out_left = win->w.left;
882 dev->chromakey_out = win->chromakey;
883 dev->global_alpha_out = win->global_alpha;
889 struct vivid_dev *dev = video_drvdata(file);
891 if (i && !dev->fmt_out->can_do_overlay) {
892 dprintk(dev, 1, "unsupported output format for output overlay\n");
896 dev->overlay_out_enabled = i;
903 struct vivid_dev *dev = video_drvdata(file);
911 a->flags = V4L2_FBUF_FLAG_OVERLAY | dev->fbuf_out_flags;
912 a->base = (void *)dev->video_pbase;
913 a->fmt.width = dev->display_width;
914 a->fmt.height = dev->display_height;
915 if (dev->fb_defined.green.length == 5)
919 a->fmt.bytesperline = dev->display_byte_stride;
930 struct vivid_dev *dev = video_drvdata(file);
949 dev->fbuf_out_flags &= ~(chroma_flags | alpha_flags);
950 dev->fbuf_out_flags |= a->flags & (chroma_flags | alpha_flags);
962 struct vivid_dev *dev = video_drvdata(file);
964 if (out->index >= dev->num_outputs)
968 switch (dev->output_type[out->index]) {
971 dev->output_name_counter[out->index]);
973 if (dev->has_audio_outputs)
979 dev->output_name_counter[out->index]);
988 struct vivid_dev *dev = video_drvdata(file);
990 *o = dev->output;
996 struct vivid_dev *dev = video_drvdata(file);
998 if (o >= dev->num_outputs)
1001 if (o == dev->output)
1004 if (vb2_is_busy(&dev->vb_vid_out_q) ||
1005 vb2_is_busy(&dev->vb_vbi_out_q) ||
1006 vb2_is_busy(&dev->vb_meta_out_q))
1009 dev->output = o;
1010 dev->tv_audio_output = 0;
1011 if (dev->output_type[o] == SVID)
1012 dev->vid_out_dev.tvnorms = V4L2_STD_ALL;
1014 dev->vid_out_dev.tvnorms = 0;
1016 dev->vbi_out_dev.tvnorms = dev->vid_out_dev.tvnorms;
1017 dev->meta_out_dev.tvnorms = dev->vid_out_dev.tvnorms;
1018 vivid_update_format_out(dev);
1020 v4l2_ctrl_activate(dev->ctrl_display_present, vivid_is_hdmi_out(dev));
1021 if (vivid_is_hdmi_out(dev))
1022 v4l2_ctrl_s_ctrl(dev->ctrl_display_present,
1023 dev->display_present[dev->output]);
1038 struct vivid_dev *dev = video_drvdata(file);
1040 if (!vivid_is_svid_out(dev))
1042 *vout = vivid_audio_outputs[dev->tv_audio_output];
1048 struct vivid_dev *dev = video_drvdata(file);
1050 if (!vivid_is_svid_out(dev))
1054 dev->tv_audio_output = vout->index;
1060 struct vivid_dev *dev = video_drvdata(file);
1062 if (!vivid_is_svid_out(dev))
1064 if (dev->std_out == id)
1066 if (vb2_is_busy(&dev->vb_vid_out_q) || vb2_is_busy(&dev->vb_vbi_out_q))
1068 dev->std_out = id;
1069 vivid_update_format_out(dev);
1087 struct vivid_dev *dev = video_drvdata(file);
1088 if (!vivid_is_hdmi_out(dev))
1094 if (v4l2_match_dv_timings(timings, &dev->dv_timings_out, 0, true))
1096 if (vb2_is_busy(&dev->vb_vid_out_q))
1098 dev->dv_timings_out = *timings;
1099 vivid_update_format_out(dev);
1106 struct vivid_dev *dev = video_drvdata(file);
1108 if (parm->type != (dev->multiplanar ?
1114 parm->parm.output.timeperframe = dev->timeperframe_vid_out;