From patchwork Tue Feb 7 16:18:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 9560555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D1E36602B1 for ; Tue, 7 Feb 2017 16:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C28A325D9E for ; Tue, 7 Feb 2017 16:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4BB52811E; Tue, 7 Feb 2017 16:19:47 +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=-1.9 required=2.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4CF8425D9E for ; Tue, 7 Feb 2017 16:19:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cb8UT-00006T-C9; Tue, 07 Feb 2017 16:19:37 +0000 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cb8UN-0008T6-De for linux-arm-kernel@lists.infradead.org; Tue, 07 Feb 2017 16:19:33 +0000 Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1cb8Te-0002Nt-Ez; Tue, 07 Feb 2017 17:18:46 +0100 Message-ID: <1486484319.2277.78.camel@pengutronix.de> Subject: [PATCH] media: imx: csi: fix crop rectangle reset in sink set_fmt From: Philipp Zabel To: Steve Longerbeam Date: Tue, 07 Feb 2017 17:18:39 +0100 In-Reply-To: <1483755102-24785-18-git-send-email-steve_longerbeam@mentor.com> References: <1483755102-24785-1-git-send-email-steve_longerbeam@mentor.com> <1483755102-24785-18-git-send-email-steve_longerbeam@mentor.com> X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170207_081931_677697_5CC00C24 X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, andrew-ct.chen@mediatek.com, minghsiu.tsai@mediatek.com, nick@shmanahar.org, songjun.wu@microchip.com, hverkuil@xs4all.nl, Steve Longerbeam , robert.jarzmik@free.fr, devel@driverdev.osuosl.org, markus.heiser@darmarIT.de, laurent.pinchart+renesas@ideasonboard.com, linux@armlinux.org.uk, geert@linux-m68k.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, arnd@arndb.de, mchehab@kernel.org, bparrot@ti.com, robh+dt@kernel.org, horms+renesas@verge.net.au, tiffany.lin@mediatek.com, linux-arm-kernel@lists.infradead.org, niklas.soderlund+renesas@ragnatech.se, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, jean-christophe.trotin@st.com, kernel@pengutronix.de, fabio.estevam@nxp.com, shawnguo@kernel.org, sudipm.mukherjee@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The csi_try_crop call in set_fmt should compare the cropping rectangle to the currently set input format, not to the previous input format. Signed-off-by: Philipp Zabel --- This is a patch against the current imx-media-staging-md-wip branch. S_FMT wouldn't update the cropping rectangle during the first time it is called, since the csi_try_crop call would compare to the input frame format returned by __csi_get_fmt, which still contains the old value. --- drivers/staging/media/imx/imx-media-csi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) crop->width = min_t(__u32, infmt->width, crop->width); @@ -1023,8 +1021,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd, crop.top = 0; crop.width = sdformat->format.width; crop.height = sdformat->format.height; - ret = csi_try_crop(priv, &crop, cfg, - sdformat->which, sensor); + ret = csi_try_crop(priv, &crop, cfg, &sdformat->format, sensor); if (ret) return ret; @@ -1104,6 +1101,7 @@ static int csi_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_mbus_framefmt *infmt; struct imx_media_subdev *sensor; int ret; @@ -1133,7 +1131,8 @@ static int csi_set_selection(struct v4l2_subdev *sd, return 0; } - ret = csi_try_crop(priv, &sel->r, cfg, sel->which, sensor); + infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sel->which); + ret = csi_try_crop(priv, &sel->r, cfg, infmt, sensor); if (ret) return ret; diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 637d0f137938a..7c590bf94fad5 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -820,15 +820,13 @@ __csi_get_fmt(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg, static int csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, struct v4l2_subdev_pad_config *cfg, - enum v4l2_subdev_format_whence which, + struct v4l2_mbus_framefmt *infmt, struct imx_media_subdev *sensor) { struct v4l2_of_endpoint *sensor_ep; - struct v4l2_mbus_framefmt *infmt; v4l2_std_id std; int ret; - infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, which); sensor_ep = &sensor->sensor_ep;