media: mtk-mdp: implement vidioc_{s,g}_crop

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Change-Id: I3900b450e1326c288c116272e93ab187567231ce
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 2a774f2..11a6a47 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -1086,10 +1086,12 @@
 	int ret;
 	bool valid = false;
 
-	if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+	if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
+	    s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
 		if (s->target == V4L2_SEL_TGT_COMPOSE)
 			valid = true;
-	} else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+	} else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT ||
+		   s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
 		if (s->target == V4L2_SEL_TGT_CROP)
 			valid = true;
 	}
@@ -1136,6 +1138,32 @@
 	return 0;
 }
 
+static int mtk_mdp_m2m_g_crop(struct file *file, void *prv,
+			      struct v4l2_crop *cr)
+{
+	struct v4l2_selection selection;
+	int ret;
+
+	ret = mtk_mdp_m2m_g_selection(file, prv, &selection);
+
+	cr->c = selection.r;
+	cr->type = selection.type;
+
+	return ret;
+}
+
+static int mtk_mdp_m2m_s_crop(struct file *file, void *prv,
+			      const struct v4l2_crop *cr)
+{
+	struct v4l2_selection selection = {
+		.type = cr->type,
+		.target = V4L2_SEL_TGT_CROP,
+		.r = cr->c,
+	};
+
+	return mtk_mdp_m2m_s_selection(file, prv, &selection);
+}
+
 static const struct v4l2_ioctl_ops mtk_mdp_m2m_ioctl_ops = {
 	.vidioc_querycap		= mtk_mdp_m2m_querycap,
 	.vidioc_enum_fmt_vid_cap_mplane	= mtk_mdp_m2m_enum_fmt_mplane_vid_cap,
@@ -1157,7 +1185,9 @@
 	.vidioc_streamon		= mtk_mdp_m2m_streamon,
 	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
 	.vidioc_g_selection		= mtk_mdp_m2m_g_selection,
-	.vidioc_s_selection		= mtk_mdp_m2m_s_selection
+	.vidioc_s_selection		= mtk_mdp_m2m_s_selection,
+	.vidioc_g_crop			= mtk_mdp_m2m_g_crop,
+	.vidioc_s_crop			= mtk_mdp_m2m_s_crop,
 };
 
 static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq,