linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: linux-media@vger.kernel.org
Cc: Steve Longerbeam <slongerbeam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v8 05/11] media: imx-csi: Double crop height for alternate fields at sink
Date: Wed,  9 Jan 2019 10:30:08 -0800	[thread overview]
Message-ID: <20190109183014.20466-6-slongerbeam@gmail.com> (raw)
In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com>

If the incoming sink field type is alternate, the reset crop height
and crop height bounds must be set to twice the incoming height,
because in alternate field mode, upstream will report only the
lines for a single field, and the CSI captures the whole frame.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/staging/media/imx/imx-media-csi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index e3a4f39dbf73..10945cbdbd71 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1142,6 +1142,8 @@ static void csi_try_crop(struct csi_priv *priv,
 			 struct v4l2_mbus_framefmt *infmt,
 			 struct v4l2_fwnode_endpoint *upstream_ep)
 {
+	u32 in_height;
+
 	crop->width = min_t(__u32, infmt->width, crop->width);
 	if (crop->left + crop->width > infmt->width)
 		crop->left = infmt->width - crop->width;
@@ -1149,6 +1151,10 @@ static void csi_try_crop(struct csi_priv *priv,
 	crop->left &= ~0x3;
 	crop->width &= ~0x7;
 
+	in_height = infmt->height;
+	if (infmt->field == V4L2_FIELD_ALTERNATE)
+		in_height *= 2;
+
 	/*
 	 * FIXME: not sure why yet, but on interlaced bt.656,
 	 * changing the vertical cropping causes loss of vertical
@@ -1158,12 +1164,12 @@ static void csi_try_crop(struct csi_priv *priv,
 	if (upstream_ep->bus_type == V4L2_MBUS_BT656 &&
 	    (V4L2_FIELD_HAS_BOTH(infmt->field) ||
 	     infmt->field == V4L2_FIELD_ALTERNATE)) {
-		crop->height = infmt->height;
-		crop->top = (infmt->height == 480) ? 2 : 0;
+		crop->height = in_height;
+		crop->top = (in_height == 480) ? 2 : 0;
 	} else {
-		crop->height = min_t(__u32, infmt->height, crop->height);
-		if (crop->top + crop->height > infmt->height)
-			crop->top = infmt->height - crop->height;
+		crop->height = min_t(__u32, in_height, crop->height);
+		if (crop->top + crop->height > in_height)
+			crop->top = in_height - crop->height;
 	}
 }
 
@@ -1403,6 +1409,8 @@ static void csi_try_fmt(struct csi_priv *priv,
 		crop->top = 0;
 		crop->width = sdformat->format.width;
 		crop->height = sdformat->format.height;
+		if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
+			crop->height *= 2;
 		csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
 		compose->left = 0;
 		compose->top = 0;
@@ -1530,6 +1538,8 @@ static int csi_get_selection(struct v4l2_subdev *sd,
 		sel->r.top = 0;
 		sel->r.width = infmt->width;
 		sel->r.height = infmt->height;
+		if (infmt->field == V4L2_FIELD_ALTERNATE)
+			sel->r.height *= 2;
 		break;
 	case V4L2_SEL_TGT_CROP:
 		sel->r = *crop;
-- 
2.17.1


  parent reply	other threads:[~2019-01-09 18:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 18:30 [PATCH v8 00/11] imx-media: Fixes for interlaced capture Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 01/11] media: videodev2.h: Add more field helper macros Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 02/11] gpu: ipu-csi: Swap fields according to input/output field types Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 03/11] gpu: ipu-v3: Add planar support to interlaced scan Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 04/11] media: imx: Fix field negotiation Steve Longerbeam
2019-01-09 18:30 ` Steve Longerbeam [this message]
2019-01-09 18:30 ` [PATCH v8 06/11] media: imx: interweave and odd-chroma-row skip are incompatible Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 07/11] media: imx-csi: Allow skipping odd chroma rows for YVU420 Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 08/11] media: imx: vdic: rely on VDIC for correct field order Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 09/11] media: imx-csi: Move crop/compose reset after filling default mbus fields Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 10/11] media: imx: Allow interweave with top/bottom lines swapped Steve Longerbeam
2019-01-09 18:30 ` [PATCH v8 11/11] media: imx.rst: Update doc to reflect fixes to interlaced capture Steve Longerbeam
2019-01-15 21:58   ` Tim Harvey
2019-01-15 23:54     ` Steve Longerbeam
2019-01-15 23:59       ` Steve Longerbeam
2019-01-21 20:24       ` Tim Harvey
2019-01-22 19:51         ` Tim Harvey
2019-01-23  0:24           ` Steve Longerbeam
2019-01-23  0:08         ` Steve Longerbeam
2019-01-23 22:04           ` Tim Harvey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190109183014.20466-6-slongerbeam@gmail.com \
    --to=slongerbeam@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).