From patchwork Tue Oct 14 06:25:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5078061 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5FE7B9F30B for ; Tue, 14 Oct 2014 06:25:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7CC5920121 for ; Tue, 14 Oct 2014 06:25:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BAA120120 for ; Tue, 14 Oct 2014 06:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753477AbaJNGZm (ORCPT ); Tue, 14 Oct 2014 02:25:42 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:40476 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753373AbaJNGZl (ORCPT ); Tue, 14 Oct 2014 02:25:41 -0400 Received: by mail-pd0-f169.google.com with SMTP id w10so6923832pde.14 for ; Mon, 13 Oct 2014 23:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2jXdFh7jCNyoNDwm07dnhWGPCdBBR+/tVV+UOfHPK3g=; b=T7IY+qd6nye3WqaLTn5q3qPG9swk8DSQBAYmwFPA2/JLu/I03Rk8eHroAoUtximin/ VbVmGhSECWUW/RtK311Zm/91QnQAcc3lbCdloVow7IlJbH75t0s0zSwqHUOGD3Y2844d 8b9fSoO0uytCYyNtjAIYAn0ExD8epIJqWVrpiCCSOhlYNe9bGrhHokOndFaOjdsrq0Lm HR2zdd0F3DpfdsMKDC0BGedEejLFoZzsJKpGSOMMSYYZUQZeuvVc9afScHXviYu5LqYJ PyBan0YdWnSUpYv3qhosfqVyPFwn179kyB7f5FR0npZLJXO8T9WJbGT4868jPdpceJgA csWw== X-Received: by 10.68.222.70 with SMTP id qk6mr2993025pbc.65.1413267941071; Mon, 13 Oct 2014 23:25:41 -0700 (PDT) Received: from localhost.localdomain (p5095-ipngn6701marunouchi.tokyo.ocn.ne.jp. [153.174.4.95]) by mx.google.com with ESMTPSA id ni1sm5507579pdb.69.2014.10.13.23.25.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 23:25:40 -0700 (PDT) From: Yoshihiro Kaneko To: linux-media@vger.kernel.org Cc: Guennadi Liakhovetski , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH] media: soc_camera: Fix VIDIOC_S_CROP ioctl miscalculation Date: Tue, 14 Oct 2014 15:25:24 +0900 Message-Id: <1413267924-8273-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Koji Matsuoka This patch corrects the miscalculation of the capture buffer size and clipping data update in VIDIOC_S_CROP sequence. Signed-off-by: Koji Matsuoka Signed-off-by: Yoshihiro Kaneko Acked-by: Simon Horman --- This patch is against master branch of linuxtv.org/media_tree.git. drivers/media/platform/soc_camera/rcar_vin.c | 5 ----- drivers/media/platform/soc_camera/soc_scale_crop.c | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 61c36b0..5196c81 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -1119,9 +1119,6 @@ static int rcar_vin_set_crop(struct soc_camera_device *icd, cam->width = mf.width; cam->height = mf.height; - icd->user_width = cam->width; - icd->user_height = cam->height; - cam->vin_left = rect->left & ~1; cam->vin_top = rect->top & ~1; @@ -1130,8 +1127,6 @@ static int rcar_vin_set_crop(struct soc_camera_device *icd, if (ret < 0) return ret; - cam->subrect = *rect; - dev_dbg(dev, "VIN cropped to %ux%u@%u:%u\n", icd->user_width, icd->user_height, cam->vin_left, cam->vin_top); diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c index 8e74fb7..7a1951a 100644 --- a/drivers/media/platform/soc_camera/soc_scale_crop.c +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c @@ -74,14 +74,14 @@ static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect) if (rect->left > subrect->left) subrect->left = rect->left; - else if (rect->left + rect->width > + else if (rect->left + rect->width < subrect->left + subrect->width) subrect->left = rect->left + rect->width - subrect->width; if (rect->top > subrect->top) subrect->top = rect->top; - else if (rect->top + rect->height > + else if (rect->top + rect->height < subrect->top + subrect->height) subrect->top = rect->top + rect->height - subrect->height; @@ -117,6 +117,7 @@ int soc_camera_client_s_crop(struct v4l2_subdev *sd, dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n", rect->width, rect->height, rect->left, rect->top); *target_rect = *cam_rect; + *subrect = *rect; return 0; } @@ -204,6 +205,7 @@ int soc_camera_client_s_crop(struct v4l2_subdev *sd, if (!ret) { *target_rect = *cam_rect; + *subrect = *rect; update_subrect(target_rect, subrect); }