Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1589883imd; Sun, 4 Nov 2018 05:56:58 -0800 (PST) X-Google-Smtp-Source: AJdET5eNOG3+ysVRUkLnLVVpHizpWpgiHWscex83MZmmUg4O4A9+U8DBa+KdzH+PrnHT1NIeqBQL X-Received: by 2002:a63:4a4a:: with SMTP id j10-v6mr17422759pgl.0.1541339818907; Sun, 04 Nov 2018 05:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541339818; cv=none; d=google.com; s=arc-20160816; b=NMqtWGbX8a2FtbN1lFrLabOEmp75g3muxmzrT9Ur8hVM5/6eZQSBt00tbCM8e/PfM4 ntrISVnk4THjqDM4rBBiVE2o8sijy9LhWrhj6zFlfdqWk+b7PaY5Onyz4Jb5Lkw+kFdN 2usq3e3HBVfurNa5xPLqHWWG8fSrZ4mOVpDbsne9ID5I+WCgtCTcBlDlz0EvcRklBFiM NPMngk/14b1DDrQ8iRO9geIVcQ5qIIOba9if13kvZWGSG1bBivEqpbXreZrv2VJrG6P8 mcbQI2iQhF1cc4BcOtqSxMY0fA/uBIxEaPr9a5DkSa4gr/sjyE0Z2Nz7JNvgvV8JDwJH 2k+A== 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=YJvm3VF+XKfG7JRA4xbLYGmLnslJ0KgYXCdppF48nPA=; b=Ts2zU57QatvDZ81ftky4mWgU806pgvKpkS4dAalFpGpjBtFb7XtSG7BYnsSZ55GR+w j3kCrDB3yT7sT/ffxX41eVDJTUa34QN74ywCbj5+osl1oZabWNBzZUsA0S1o6g+yW0ds n7TEmGaPOvQVHfUzQGXbLcJaBGdew+LfsCXjKTBWfyPsCso8rkFhslcqauLTSW7OweJi 8cEa0FXA+JnKV+zjEGXh2AiPgUozzXI/6BuAd6m14ZagI6YEtnLq3FM3NjkLdjsKbSyO h4XV8Qvpg/2jvhsCzaXO5w1C0p8gPAnYok8qSPoTam+nobZdcuV4jke5W5IfbZJjdFuz PTtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KXKmxSQz; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si40921781pgn.512.2018.11.04.05.56.44; Sun, 04 Nov 2018 05:56:58 -0800 (PST) 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=@kernel.org header.s=default header.b=KXKmxSQz; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731430AbeKDXI7 (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:48192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731356AbeKDXI4 (ORCPT ); Sun, 4 Nov 2018 18:08:56 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CE7C20866; Sun, 4 Nov 2018 13:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339632; bh=U3mw5PiduQLSFbywe6ibS2t5xSUmJBdomGwYIn1Wg2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXKmxSQzxs0vOHiExUNS/sI2ivZNv+YVH7KzDbb+Nf2nJupDAdPaH02c3yu7mLrZG 0+vvxO1cN4wWxeWne/fG4832pXKMf0B9FsXUwLjNcZUmAJqGZjMe6qaMjT2sOZnPOq XW5CGyqpTPdu/pzMyev3iAYTbGUPnn5cCBJVxQbI= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marco Felsch , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH AUTOSEL 4.14 26/30] media: tvp5150: fix width alignment during set_selection() Date: Sun, 4 Nov 2018 08:53:21 -0500 Message-Id: <20181104135325.88524-26-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marco Felsch [ Upstream commit bd24db04101f45a9c1d874fe21b0c7eab7bcadec ] The driver ignored the width alignment which exists due to the UYVY colorspace format. Fix the width alignment and make use of the the provided v4l2 helper function to set the width, height and all alignments in one. Fixes: 963ddc63e20d ("[media] media: tvp5150: Add cropping support") Signed-off-by: Marco Felsch Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/tvp5150.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 59b0c1fce9be..a0e461e99ecb 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -900,9 +900,6 @@ static int tvp5150_set_selection(struct v4l2_subdev *sd, /* tvp5150 has some special limits */ rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT); - rect.width = clamp_t(unsigned int, rect.width, - TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left, - TVP5150_H_MAX - rect.left); rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP); /* Calculate height based on current standard */ @@ -916,9 +913,16 @@ static int tvp5150_set_selection(struct v4l2_subdev *sd, else hmax = TVP5150_V_MAX_OTHERS; - rect.height = clamp_t(unsigned int, rect.height, + /* + * alignments: + * - width = 2 due to UYVY colorspace + * - height, image = no special alignment + */ + v4l_bound_align_image(&rect.width, + TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left, + TVP5150_H_MAX - rect.left, 1, &rect.height, hmax - TVP5150_MAX_CROP_TOP - rect.top, - hmax - rect.top); + hmax - rect.top, 0, 0); tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top); tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, -- 2.17.1