From patchwork Wed Apr 29 17:05:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6297171 X-Patchwork-Delegate: geert@linux-m68k.org 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4F27F9F373 for ; Wed, 29 Apr 2015 17:06:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DD4A201BB for ; Wed, 29 Apr 2015 17:06:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B5DE20160 for ; Wed, 29 Apr 2015 17:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966000AbbD2RGR (ORCPT ); Wed, 29 Apr 2015 13:06:17 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34289 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753716AbbD2RGP (ORCPT ); Wed, 29 Apr 2015 13:06:15 -0400 Received: by pacyx8 with SMTP id yx8so33257342pac.1; Wed, 29 Apr 2015 10:06:15 -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=KREe7JD7bO6EUTo5s/JBOXJMEa6ZJLWTpMuL/Vvraq8=; b=YH+RQAqVVfO0Dok46QCiDft7PrAZFGX4BpbTuSvLs1k9sXHBHFd5GEMyzzEPdVjZio h0CaX9OLfWd82ZiEYqZGX2gCWCI9ZW6aoh8m6ujTnnwJ4ajGAEJCnrJcDMe0kqBJ5+9W MQDDRuueBoFOSimYxMzF8moWaWHq+sbWlYK/BLTe2duTk+YHo8tH/0b3qSqZJ7dXgxPp 3Whzy8SAsr/+Cxoo2mJT9uVzPTNlCfqL0EmJQzXTxKxNHryaTO13sUhSLSm3N04j3at4 ZG7GPgZ2IncqLw+3vqEO501oXemT9lZALCkkWzyIMsmUr8NGcasAL85KwldHdOB451vw xALQ== X-Received: by 10.68.229.136 with SMTP id sq8mr79418pbc.160.1430327174895; Wed, 29 Apr 2015 10:06:14 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id ez1sm25901780pbd.0.2015.04.29.10.06.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Apr 2015 10:06:14 -0700 (PDT) From: Yoshihiro Kaneko To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Laurent Pinchart , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH/RFC] v4l: vsp1: Align crop rectangle to even boundary for YUV formats Date: Thu, 30 Apr 2015 02:05:33 +0900 Message-Id: <1430327133-8461-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: Damian Hobson-Garcia Make sure that there are valid values in the crop rectangle to ensure that the color plane doesn't get shifted when cropping. Since there is no distintion between 12bit and 16bit YUV formats in at the subdev level, use the more restrictive 12bit limits for all YUV formats. Signed-off-by: Damian Hobson-Garcia Signed-off-by: Yoshihiro Kaneko --- This patch is based on the master branch of linuxtv.org/media_tree.git. drivers/media/platform/vsp1/vsp1_rwpf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c index fa71f46..9fed0b2 100644 --- a/drivers/media/platform/vsp1/vsp1_rwpf.c +++ b/drivers/media/platform/vsp1/vsp1_rwpf.c @@ -197,11 +197,21 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev, */ format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, RWPF_PAD_SINK, sel->which); + + if (format->code == MEDIA_BUS_FMT_AYUV8_1X32) { + sel->r.left = (sel->r.left + 1) & ~1; + sel->r.top = (sel->r.top + 1) & ~1; + sel->r.width = (sel->r.width) & ~1; + sel->r.height = (sel->r.height) & ~1; + } + sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); if (rwpf->entity.type == VSP1_ENTITY_WPF) { - sel->r.left = min_t(unsigned int, sel->r.left, 255); - sel->r.top = min_t(unsigned int, sel->r.top, 255); + int maxcrop = + format->code == MEDIA_BUS_FMT_AYUV8_1X32 ? 254 : 255; + sel->r.left = min_t(unsigned int, sel->r.left, maxcrop); + sel->r.top = min_t(unsigned int, sel->r.top, maxcrop); } sel->r.width = min_t(unsigned int, sel->r.width, format->width - sel->r.left);