Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1337757imm; Thu, 4 Oct 2018 11:55:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62iVDEdQvAzBR/JlNdYGpKq9VZZ2d1464/de++2xg9k47kvtmKMSKzjfliZfqVu+s3GndnW X-Received: by 2002:a62:e057:: with SMTP id f84-v6mr8103363pfh.208.1538679359049; Thu, 04 Oct 2018 11:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538679359; cv=none; d=google.com; s=arc-20160816; b=IxHdjbhVdNrDDUidCAWyjD9XKLmH/Kdn0M5rGBxI7qrrUjRHk2t42RXBR1YeIDUljn RT37tl9olUAqj4IcwPpvAC8GnW5UJvR+9oYHF7gzbfsCCg5xuFvPBigQXYbGmUWaQ+LY VNyt7luHkvrlIwRNmnyhdK2JtbuiekQwJ4kRVnq0nXqKreoEHOIWhbuAIlPCE6hWTmhZ Sc0lzMmWdneVJU3Zf8IPlk773yMyY+XM40WVr+P7SAUw6qu2w0XfwTblSk4+cTNddltc 0mMG++RksaapOnXtYkCAia/i12rMYxsb++1fvTH3VWnRjEtVlRuVT0v6Isdprkb+HyBQ 47IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tfj0/FpPhXWz4+R+laujVpeT7NrSAQzRT3T/DZOBYiE=; b=sqtbOF+2twuBmnqWJHBV69Sr96PX6XQ4fVxWcSNE6dZZwQR8Rcuc89pQ4VZ2Ocg0Pw itHbynDLj5sIpqfHk1zsxVa1GprzbGF8HK/OmKUxMhhKRuoMVbxZl3Nl5ZvKs2qXbVw7 VwZeuSdzM6/y5MHFeuf1Cz8ID1DkescEHmo/r9j+SKosAECYyRABc6phJ7osr1sx5jyA SUBZHzYM7jhFhe1Lc6xVEFyv7q8+lpvZHTPAmPbWAZnpBBsgk+vGBEmxMBK5/wqkf74G QYmdoPzs6r4T1l7+ewcy1So8+T8TCe4hP1BhzJqzYOwVJcgA1U2swYUlAF90e7inmX+I tgnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X5bNpsaC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9-v6si5513769pgi.227.2018.10.04.11.55.43; Thu, 04 Oct 2018 11:55:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X5bNpsaC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728265AbeJEBtB (ORCPT + 99 others); Thu, 4 Oct 2018 21:49:01 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46294 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728116AbeJEBtA (ORCPT ); Thu, 4 Oct 2018 21:49:00 -0400 Received: by mail-wr1-f67.google.com with SMTP id a2-v6so3975935wrc.13; Thu, 04 Oct 2018 11:54:26 -0700 (PDT) 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=tfj0/FpPhXWz4+R+laujVpeT7NrSAQzRT3T/DZOBYiE=; b=X5bNpsaCXcvEH6bpWndqGPpexi37fZeicZJ4+IlhJ9Neh0/FsoW0Lfwvz7eA3dnFkT DSDjvVjhd/6BHC3Kxr3p+E9F+WVDsMDtNdNP5x1FZRdsDlSgmAMNVrHD3uZ3kflLK0C4 XdzomSFEz6Gut0BKsLCQ527nEh8JVzvH+tzGG8QnX1prdCTGXbEzZIjSc6aeGIPPGazN y26eP2nNRnjMKacJR4gdfPuMfbG6V27ifHfWe81QY4JMYPyterSZqoLxaahWrtNkCjXS vzeS2SpWiknErnx9r3/brZhLs3BKzdP9nqXID3A9I9UskoPpUJF9JcXQxYpO43W3EQM9 HGgg== 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=tfj0/FpPhXWz4+R+laujVpeT7NrSAQzRT3T/DZOBYiE=; b=g7flR6Y+XojqVXt8P3t89Uj3mnIAlbysUhk8HQ0pMCib/oStpMkJU+d59BD+pKDYFW 5ESeEWBYNxdYkIQWeeDS2MMJgB1XoAVr940Meu2hHe2yKxSYhdFXiRdaUZEI3GsJykkn r0sAyN9vJiEau5rgpIXq+siSJvpqUSo1jg7/xaIH9h4EKHA13DfTutV/GPc7Jf3rI2CR 28XjPeuuKpSVMiBAWrz2rQyZRUzmUjSZMWV5swwB9fwB4m3ybaZLMKs4rBqJ7kOWeA3J P5P220vEcMvqLgaFZscLRq0XX2cZvnEAlB9cksAgY2ZwpSn67uUhuV6MUa8ZWZ6sxfRw Bp5w== X-Gm-Message-State: ABuFfoiSt+xWeV2Txq8AstvYTfkM97AoRilOqzDo+iz5m63sD1fgf11B +gSbZ663KSGzB8gC9vu8PkkV4YhK X-Received: by 2002:adf:a781:: with SMTP id j1-v6mr3232104wrc.277.1538679265132; Thu, 04 Oct 2018 11:54:25 -0700 (PDT) Received: from mappy.world.mentorg.com (nat-wv.mentorg.com. [192.94.38.34]) by smtp.gmail.com with ESMTPSA id h78-v6sm8706877wmd.4.2018.10.04.11.54.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 11:54:24 -0700 (PDT) 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 v4 05/11] media: imx-csi: Double crop height for alternate fields at sink Date: Thu, 4 Oct 2018 11:53:55 -0700 Message-Id: <20181004185401.15751-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181004185401.15751-1-slongerbeam@gmail.com> References: <20181004185401.15751-1-slongerbeam@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 764db0d7c6d3..ca6328f53b75 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1138,6 +1138,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; @@ -1145,6 +1147,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 @@ -1154,12 +1160,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; } } @@ -1399,6 +1405,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; @@ -1526,6 +1534,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