Lines Matching refs:vin
87 const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin, in rvin_format_from_pixel() argument
94 if (vin->info->model == RCAR_M1) in rvin_format_from_pixel()
102 if (!vin->info->nv12 || !(BIT(vin->id) & 0x3333)) in rvin_format_from_pixel()
116 static u32 rvin_format_bytesperline(struct rvin_dev *vin, in rvin_format_bytesperline() argument
122 fmt = rvin_format_from_pixel(vin, pix->pixelformat); in rvin_format_bytesperline()
155 static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix) in rvin_format_align() argument
159 if (!rvin_format_from_pixel(vin, pix->pixelformat)) in rvin_format_align()
197 v4l_bound_align_image(&pix->width, 5, vin->info->max_width, walign, in rvin_format_align()
198 &pix->height, 2, vin->info->max_height, 0, 0); in rvin_format_align()
200 pix->bytesperline = rvin_format_bytesperline(vin, pix); in rvin_format_align()
203 vin_dbg(vin, "Format %ux%u bpl: %u size: %u\n", in rvin_format_align()
211 static int rvin_reset_format(struct rvin_dev *vin) in rvin_reset_format() argument
215 .pad = vin->parallel.source_pad, in rvin_reset_format()
219 ret = v4l2_subdev_call(vin_to_source(vin), pad, get_fmt, NULL, &fmt); in rvin_reset_format()
223 v4l2_fill_pix_format(&vin->format, &fmt.format); in rvin_reset_format()
225 vin->src_rect.top = 0; in rvin_reset_format()
226 vin->src_rect.left = 0; in rvin_reset_format()
227 vin->src_rect.width = vin->format.width; in rvin_reset_format()
228 vin->src_rect.height = vin->format.height; in rvin_reset_format()
231 if (vin->format.field == V4L2_FIELD_ALTERNATE) { in rvin_reset_format()
232 vin->format.field = V4L2_FIELD_INTERLACED; in rvin_reset_format()
233 vin->format.height *= 2; in rvin_reset_format()
236 rvin_format_align(vin, &vin->format); in rvin_reset_format()
238 vin->crop = vin->src_rect; in rvin_reset_format()
240 vin->compose.top = 0; in rvin_reset_format()
241 vin->compose.left = 0; in rvin_reset_format()
242 vin->compose.width = vin->format.width; in rvin_reset_format()
243 vin->compose.height = vin->format.height; in rvin_reset_format()
248 static int rvin_try_format(struct rvin_dev *vin, u32 which, in rvin_try_format() argument
252 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_try_format()
256 .pad = vin->parallel.source_pad, in rvin_try_format()
266 if (!rvin_format_from_pixel(vin, pix->pixelformat)) in rvin_try_format()
269 v4l2_fill_mbus_format(&format.format, pix, vin->mbus_code); in rvin_try_format()
296 rvin_format_align(vin, pix); in rvin_try_format()
306 struct rvin_dev *vin = video_drvdata(file); in rvin_querycap() local
311 dev_name(vin->dev)); in rvin_querycap()
318 struct rvin_dev *vin = video_drvdata(file); in rvin_try_fmt_vid_cap() local
320 return rvin_try_format(vin, V4L2_SUBDEV_FORMAT_TRY, &f->fmt.pix, NULL); in rvin_try_fmt_vid_cap()
326 struct rvin_dev *vin = video_drvdata(file); in rvin_s_fmt_vid_cap() local
330 if (vb2_is_busy(&vin->queue)) in rvin_s_fmt_vid_cap()
333 ret = rvin_try_format(vin, V4L2_SUBDEV_FORMAT_ACTIVE, &f->fmt.pix, in rvin_s_fmt_vid_cap()
338 vin->format = f->fmt.pix; in rvin_s_fmt_vid_cap()
342 fmt_rect.width = vin->format.width; in rvin_s_fmt_vid_cap()
343 fmt_rect.height = vin->format.height; in rvin_s_fmt_vid_cap()
345 v4l2_rect_map_inside(&vin->crop, &src_rect); in rvin_s_fmt_vid_cap()
346 v4l2_rect_map_inside(&vin->compose, &fmt_rect); in rvin_s_fmt_vid_cap()
347 vin->src_rect = src_rect; in rvin_s_fmt_vid_cap()
355 struct rvin_dev *vin = video_drvdata(file); in rvin_g_fmt_vid_cap() local
357 f->fmt.pix = vin->format; in rvin_g_fmt_vid_cap()
365 struct rvin_dev *vin = video_drvdata(file); in rvin_enum_fmt_vid_cap() local
414 if (rvin_format_from_pixel(vin, rvin_formats[i].fourcc)) in rvin_enum_fmt_vid_cap()
429 struct rvin_dev *vin = video_drvdata(file); in rvin_g_selection() local
438 s->r.width = vin->src_rect.width; in rvin_g_selection()
439 s->r.height = vin->src_rect.height; in rvin_g_selection()
442 s->r = vin->crop; in rvin_g_selection()
447 s->r.width = vin->format.width; in rvin_g_selection()
448 s->r.height = vin->format.height; in rvin_g_selection()
451 s->r = vin->compose; in rvin_g_selection()
463 struct rvin_dev *vin = video_drvdata(file); in rvin_s_selection() local
481 max_rect.width = vin->src_rect.width; in rvin_s_selection()
482 max_rect.height = vin->src_rect.height; in rvin_s_selection()
485 v4l_bound_align_image(&r.width, 6, vin->src_rect.width, 0, in rvin_s_selection()
486 &r.height, 2, vin->src_rect.height, 0, 0); in rvin_s_selection()
489 vin->src_rect.height - r.height); in rvin_s_selection()
490 r.left = clamp_t(s32, r.left, 0, vin->src_rect.width - r.width); in rvin_s_selection()
492 vin->crop = s->r = r; in rvin_s_selection()
494 vin_dbg(vin, "Cropped %dx%d@%d:%d of %dx%d\n", in rvin_s_selection()
496 vin->src_rect.width, vin->src_rect.height); in rvin_s_selection()
501 max_rect.width = vin->format.width; in rvin_s_selection()
502 max_rect.height = vin->format.height; in rvin_s_selection()
510 while ((r.top * vin->format.bytesperline) & HW_BUFFER_MASK) in rvin_s_selection()
513 fmt = rvin_format_from_pixel(vin, vin->format.pixelformat); in rvin_s_selection()
517 vin->compose = s->r = r; in rvin_s_selection()
519 vin_dbg(vin, "Compose %dx%d@%d:%d in %dx%d\n", in rvin_s_selection()
521 vin->format.width, vin->format.height); in rvin_s_selection()
528 rvin_crop_scale_comp(vin); in rvin_s_selection()
536 struct rvin_dev *vin = video_drvdata(file); in rvin_g_pixelaspect() local
537 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_g_pixelaspect()
548 struct rvin_dev *vin = video_drvdata(file); in rvin_enum_input() local
549 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_enum_input()
566 i->std = vin->vdev.tvnorms; in rvin_enum_input()
589 struct rvin_dev *vin = video_drvdata(file); in rvin_querystd() local
590 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_querystd()
597 struct rvin_dev *vin = video_drvdata(file); in rvin_s_std() local
600 ret = v4l2_subdev_call(vin_to_source(vin), video, s_std, a); in rvin_s_std()
604 vin->std = a; in rvin_s_std()
607 return rvin_reset_format(vin); in rvin_s_std()
612 struct rvin_dev *vin = video_drvdata(file); in rvin_g_std() local
614 if (v4l2_subdev_has_op(vin_to_source(vin), pad, dv_timings_cap)) in rvin_g_std()
617 *a = vin->std; in rvin_g_std()
635 struct rvin_dev *vin = video_drvdata(file); in rvin_enum_dv_timings() local
636 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_enum_dv_timings()
642 timings->pad = vin->parallel.sink_pad; in rvin_enum_dv_timings()
654 struct rvin_dev *vin = video_drvdata(file); in rvin_s_dv_timings() local
655 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_s_dv_timings()
663 return rvin_reset_format(vin); in rvin_s_dv_timings()
669 struct rvin_dev *vin = video_drvdata(file); in rvin_g_dv_timings() local
670 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_g_dv_timings()
678 struct rvin_dev *vin = video_drvdata(file); in rvin_query_dv_timings() local
679 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_query_dv_timings()
687 struct rvin_dev *vin = video_drvdata(file); in rvin_dv_timings_cap() local
688 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_dv_timings_cap()
694 cap->pad = vin->parallel.sink_pad; in rvin_dv_timings_cap()
705 struct rvin_dev *vin = video_drvdata(file); in rvin_g_edid() local
706 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_g_edid()
712 edid->pad = vin->parallel.sink_pad; in rvin_g_edid()
723 struct rvin_dev *vin = video_drvdata(file); in rvin_s_edid() local
724 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_s_edid()
730 edid->pad = vin->parallel.sink_pad; in rvin_s_edid()
787 static void rvin_mc_try_format(struct rvin_dev *vin, in rvin_mc_try_format() argument
802 rvin_format_align(vin, pix); in rvin_mc_try_format()
808 struct rvin_dev *vin = video_drvdata(file); in rvin_mc_try_fmt_vid_cap() local
810 rvin_mc_try_format(vin, &f->fmt.pix); in rvin_mc_try_fmt_vid_cap()
818 struct rvin_dev *vin = video_drvdata(file); in rvin_mc_s_fmt_vid_cap() local
820 if (vb2_is_busy(&vin->queue)) in rvin_mc_s_fmt_vid_cap()
823 rvin_mc_try_format(vin, &f->fmt.pix); in rvin_mc_s_fmt_vid_cap()
825 vin->format = f->fmt.pix; in rvin_mc_s_fmt_vid_cap()
827 vin->crop.top = 0; in rvin_mc_s_fmt_vid_cap()
828 vin->crop.left = 0; in rvin_mc_s_fmt_vid_cap()
829 vin->crop.width = vin->format.width; in rvin_mc_s_fmt_vid_cap()
830 vin->crop.height = vin->format.height; in rvin_mc_s_fmt_vid_cap()
831 vin->compose = vin->crop; in rvin_mc_s_fmt_vid_cap()
862 static int rvin_power_parallel(struct rvin_dev *vin, bool on) in rvin_power_parallel() argument
864 struct v4l2_subdev *sd = vin_to_source(vin); in rvin_power_parallel()
877 struct rvin_dev *vin = video_drvdata(file); in rvin_open() local
880 ret = pm_runtime_resume_and_get(vin->dev); in rvin_open()
884 ret = mutex_lock_interruptible(&vin->lock); in rvin_open()
888 file->private_data = vin; in rvin_open()
894 if (vin->info->use_mc) in rvin_open()
895 ret = v4l2_pipeline_pm_get(&vin->vdev.entity); in rvin_open()
897 ret = rvin_power_parallel(vin, true); in rvin_open()
902 ret = v4l2_ctrl_handler_setup(&vin->ctrl_handler); in rvin_open()
906 mutex_unlock(&vin->lock); in rvin_open()
910 if (vin->info->use_mc) in rvin_open()
911 v4l2_pipeline_pm_put(&vin->vdev.entity); in rvin_open()
913 rvin_power_parallel(vin, false); in rvin_open()
917 mutex_unlock(&vin->lock); in rvin_open()
919 pm_runtime_put(vin->dev); in rvin_open()
926 struct rvin_dev *vin = video_drvdata(file); in rvin_release() local
930 mutex_lock(&vin->lock); in rvin_release()
938 if (vin->info->use_mc) { in rvin_release()
939 v4l2_pipeline_pm_put(&vin->vdev.entity); in rvin_release()
942 rvin_power_parallel(vin, false); in rvin_release()
945 mutex_unlock(&vin->lock); in rvin_release()
947 pm_runtime_put(vin->dev); in rvin_release()
962 void rvin_v4l2_unregister(struct rvin_dev *vin) in rvin_v4l2_unregister() argument
964 if (!video_is_registered(&vin->vdev)) in rvin_v4l2_unregister()
967 v4l2_info(&vin->v4l2_dev, "Removing %s\n", in rvin_v4l2_unregister()
968 video_device_node_name(&vin->vdev)); in rvin_v4l2_unregister()
971 video_unregister_device(&vin->vdev); in rvin_v4l2_unregister()
974 static void rvin_notify_video_device(struct rvin_dev *vin, in rvin_notify_video_device() argument
979 v4l2_event_queue(&vin->vdev, arg); in rvin_notify_video_device()
992 struct rvin_dev *vin = in rvin_notify() local
997 if (!vin->info->use_mc) { in rvin_notify()
998 rvin_notify_video_device(vin, notification, arg); in rvin_notify()
1002 group = vin->group; in rvin_notify()
1005 vin = group->vin[i]; in rvin_notify()
1006 if (!vin) in rvin_notify()
1009 pad = media_entity_remote_pad(&vin->pad); in rvin_notify()
1017 rvin_notify_video_device(vin, notification, arg); in rvin_notify()
1021 int rvin_v4l2_register(struct rvin_dev *vin) in rvin_v4l2_register() argument
1023 struct video_device *vdev = &vin->vdev; in rvin_v4l2_register()
1026 vin->v4l2_dev.notify = rvin_notify; in rvin_v4l2_register()
1029 vdev->v4l2_dev = &vin->v4l2_dev; in rvin_v4l2_register()
1030 vdev->queue = &vin->queue; in rvin_v4l2_register()
1031 snprintf(vdev->name, sizeof(vdev->name), "VIN%u output", vin->id); in rvin_v4l2_register()
1033 vdev->lock = &vin->lock; in rvin_v4l2_register()
1039 vin->format.pixelformat = RVIN_DEFAULT_FORMAT; in rvin_v4l2_register()
1040 vin->format.width = RVIN_DEFAULT_WIDTH; in rvin_v4l2_register()
1041 vin->format.height = RVIN_DEFAULT_HEIGHT; in rvin_v4l2_register()
1042 vin->format.field = RVIN_DEFAULT_FIELD; in rvin_v4l2_register()
1043 vin->format.colorspace = RVIN_DEFAULT_COLORSPACE; in rvin_v4l2_register()
1045 if (vin->info->use_mc) { in rvin_v4l2_register()
1050 rvin_reset_format(vin); in rvin_v4l2_register()
1053 rvin_format_align(vin, &vin->format); in rvin_v4l2_register()
1055 ret = video_register_device(&vin->vdev, VFL_TYPE_VIDEO, -1); in rvin_v4l2_register()
1057 vin_err(vin, "Failed to register video device\n"); in rvin_v4l2_register()
1061 video_set_drvdata(&vin->vdev, vin); in rvin_v4l2_register()
1063 v4l2_info(&vin->v4l2_dev, "Device registered as %s\n", in rvin_v4l2_register()
1064 video_device_node_name(&vin->vdev)); in rvin_v4l2_register()