From patchwork Wed Jan 9 00:15:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10753175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A3FF13B5 for ; Wed, 9 Jan 2019 00:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E870928C8B for ; Wed, 9 Jan 2019 00:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC8CD28C9C; Wed, 9 Jan 2019 00:17:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6797028C0C for ; Wed, 9 Jan 2019 00:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbfAIAQ7 (ORCPT ); Tue, 8 Jan 2019 19:16:59 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35024 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729441AbfAIAQJ (ORCPT ); Tue, 8 Jan 2019 19:16:09 -0500 Received: by mail-pl1-f195.google.com with SMTP id p8so2688572plo.2; Tue, 08 Jan 2019 16:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+gWCj7jpvSU77lLytUOhuIltx3JiK4hVtYn+wZJtUfw=; b=q5G56hB3/UtigqYXXaajaktbTSpAcYphGCWMngYN20YMS2sLaoqJ0btQpqQQtyernT wZLxt+Gn/LBlidqla7kym+q5m5v3v4Jv/WkExVsRYmSchHWQcZUDIne/p6aSuDgGho9g x0OyiMQhTagByfTgml8soqLgbEP0zYUQXNAzuagZgJtSz4VSrsOW1Q4KmuKgaNXhhhVO OrY9WmxLy8KMMnS1ZwvfA8GIdJYSFIYvwyyRckAp9n/Iu2NNpzfI40P7z1W6oYg661gN gi0EvIBN+EYTb23sjMzGh2t/VECoAT1J2HObhvJD7tHEz1qBHI3axPTnfYlwwvNfq3Pc Y1Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+gWCj7jpvSU77lLytUOhuIltx3JiK4hVtYn+wZJtUfw=; b=q7Vc/JJvPQ3d/DZOVPyvWl3/wNv03dW5w01qA19hcsh7NAp4U1aYZEfHsQ1zPkaXcZ dZTxT+BxJrqp+Qt/0/ReFzCEz6QtD11Z6ICyCFDqSFmmxYj/YHMzHTALI8YqdbbsWluw aKbV1W1RwMiZqlnwNVvQTc5A7FjhbBl3KiF6w+a1dlGzavQEOLuA0Xpo4WxbMkGsqyyF 07cRsGDRlwjkdMdMgsUBDa62KiegGl/jbhnOYZCqBTMFhDXxyyDf3OxjDlBgKmfUa6Ys qUcPw5LQXYAc5q/hFUFqwwb85Yt3o22V8s35YQlH4HDIOpuj8CgYvGbx4+klvTLH3+Mp +j2A== X-Gm-Message-State: AJcUukdRbN/m2UBC3IrUjtkeWejfIw8IulzucMeprHTMTY5gmHxGV6It 0lVBg4gEK3wfV4XKc9EefWU8mq5A X-Google-Smtp-Source: ALg8bN7vwSQNPhHu8DLr+fcN9skgUteAg2/eBG1ARIAKhAYPSGytmUXbrMam4h/VdhQICMXin4nvcw== X-Received: by 2002:a17:902:7201:: with SMTP id ba1mr3845000plb.105.1546992968556; Tue, 08 Jan 2019 16:16:08 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id 134sm83978490pgb.78.2019.01.08.16.16.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 16:16:07 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 06/12] media: imx-csi: Double crop height for alternate fields at sink Date: Tue, 8 Jan 2019 16:15:45 -0800 Message-Id: <20190109001551.16113-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109001551.16113-1-slongerbeam@gmail.com> References: <20190109001551.16113-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Philipp Zabel --- 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 b276672cae1d..c40c3262038e 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;