From patchwork Fri May 11 09:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10393813 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 E28FC60153 for ; Fri, 11 May 2018 10:00:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA09928DFA for ; Fri, 11 May 2018 10:00:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E4B228E62; Fri, 11 May 2018 10:00:00 +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=-7.9 required=2.0 tests=BAYES_00, 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 233ED28E61 for ; Fri, 11 May 2018 10:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752656AbeEKJ76 (ORCPT ); Fri, 11 May 2018 05:59:58 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:59793 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbeEKJ7x (ORCPT ); Fri, 11 May 2018 05:59:53 -0400 Received: from w540.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 0A31D200008; Fri, 11 May 2018 11:59:51 +0200 (CEST) From: Jacopo Mondi To: niklas.soderlund@ragnatech.se, laurent.pinchart@ideasonboard.com Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH 4/5] media: rcar-vin: Do not use crop if not configured Date: Fri, 11 May 2018 11:59:40 +0200 Message-Id: <1526032781-14319-5-git-send-email-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526032781-14319-1-git-send-email-jacopo+renesas@jmondi.org> References: <1526032781-14319-1-git-send-email-jacopo+renesas@jmondi.org> 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 The crop_scale routine uses the crop rectangle memebers to configure the VIN clipping rectangle. When crop is not configured all its fields are 0s, and setting the clipping rectangle vertical and horizontal extensions to (0 - 1) causes the registers to be written with an incorrect 0xffffffff value. Fix this by using the actual format width and height when no crop rectangle has been programmed. Signed-off-by: Jacopo Mondi --- drivers/media/platform/rcar-vin/rcar-dma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index b41ba9a..ea7a120 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -579,22 +579,25 @@ static void rvin_crop_scale_comp_gen2(struct rvin_dev *vin) void rvin_crop_scale_comp(struct rvin_dev *vin) { - /* Set Start/End Pixel/Line Pre-Clip */ + u32 width = vin->crop.width ? vin->crop.left + vin->crop.width : + vin->format.width; + u32 height = vin->crop.height ? vin->crop.top + vin->crop.height : + vin->format.height; + + /* Set Start/End Pixel/Line Pre-Clip if crop is configured. */ rvin_write(vin, vin->crop.left, VNSPPRC_REG); - rvin_write(vin, vin->crop.left + vin->crop.width - 1, VNEPPRC_REG); + rvin_write(vin, width - 1, VNEPPRC_REG); switch (vin->format.field) { case V4L2_FIELD_INTERLACED: case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: rvin_write(vin, vin->crop.top / 2, VNSLPRC_REG); - rvin_write(vin, (vin->crop.top + vin->crop.height) / 2 - 1, - VNELPRC_REG); + rvin_write(vin, height / 2 - 1, VNELPRC_REG); break; default: rvin_write(vin, vin->crop.top, VNSLPRC_REG); - rvin_write(vin, vin->crop.top + vin->crop.height - 1, - VNELPRC_REG); + rvin_write(vin, height - 1, VNELPRC_REG); break; }