From patchwork Tue Oct 21 05:10:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5110331 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 401CDC11AD for ; Tue, 21 Oct 2014 05:10:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FAED201D3 for ; Tue, 21 Oct 2014 05:10:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BDA72015A for ; Tue, 21 Oct 2014 05:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751664AbaJUFKp (ORCPT ); Tue, 21 Oct 2014 01:10:45 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:41169 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbaJUFKn (ORCPT ); Tue, 21 Oct 2014 01:10:43 -0400 Received: by mail-pa0-f54.google.com with SMTP id ey11so563991pad.41 for ; Mon, 20 Oct 2014 22:10:43 -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:in-reply-to:references; bh=wChtX9vQLGE0S+04RX3xllQztZXmHYG2A3SHhx82xi0=; b=mnJjLEDZqAndViwpkTCWxxUY5CVf80BH1JILSW95PyFPZIcaBlQ06sjFcd3Qz2kN1R i+gDBx1REW0UW1mElhlG5b8Iursus+WDOQJ+0RjrMinJzs81h6cYnl5h/SGitGMSzUO5 lz4ZGF1jyR9TJgzKXwavpOhy7BEMA1UXSPQQj5BK5ZMO1js9folQpx23l8A3lXhLdBf1 n6vTxWNA7GK5dvrEpQzvUsTROS+r4o9xLw91IQS2qXPUOmFXFjx4Ge2pPHWh0tJUpD4X tfUxYMf7N1z6hEvyV4CHmc667QjecyI+9mLDPD5f8TdaHx0GrauG6vD1+F8AVnt7/pPf Iuww== X-Received: by 10.66.187.173 with SMTP id ft13mr31770418pac.41.1413868243298; Mon, 20 Oct 2014 22:10:43 -0700 (PDT) Received: from localhost.localdomain (p5095-ipngn6701marunouchi.tokyo.ocn.ne.jp. [153.174.4.95]) by mx.google.com with ESMTPSA id fv3sm1567790pac.7.2014.10.20.22.10.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Oct 2014 22:10:42 -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 v3 2/3] media: soc_camera: rcar_vin: Add capture width check for NV16 format Date: Tue, 21 Oct 2014 14:10:28 +0900 Message-Id: <1413868229-22205-3-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413868229-22205-1-git-send-email-ykaneko0929@gmail.com> References: <1413868229-22205-1-git-send-email-ykaneko0929@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 At the time of NV16 capture format, the user has to specify the capture output width of the multiple of 32 for H/W specification. At the time of using NV16 format by ioctl of VIDIOC_S_FMT, this patch adds align check and the error handling to forbid specification of the capture output width which is not a multiple of 32. Signed-off-by: Koji Matsuoka Signed-off-by: Yoshihiro Kaneko --- v3 [Yoshihiro Kaneko] * fixes some code-style and remove useless error flag as suggested by Sergei Shtylyov v2 [Yoshihiro Kaneko] * use u32 instead of unsigned long drivers/media/platform/soc_camera/rcar_vin.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index dd6daab..ecdbd48 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -644,7 +644,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv) /* output format */ switch (icd->current_fmt->host_fmt->fourcc) { case V4L2_PIX_FMT_NV16: - iowrite32(ALIGN(cam->width * cam->height, 0x80), + iowrite32(ALIGN(ALIGN(cam->width, 0x20) * cam->height, 0x80), priv->base + VNUVAOF_REG); dmr = VNDMR_DTMD_YCSEP; output_is_yuv = true; @@ -1086,6 +1086,7 @@ static int rcar_vin_set_rect(struct soc_camera_device *icd) unsigned char dsize = 0; struct v4l2_rect *cam_subrect = &cam->subrect; u32 value; + u32 vnis; dev_dbg(icd->parent, "Crop %ux%u@%u:%u\n", icd->user_width, icd->user_height, cam->vin_left, cam->vin_top); @@ -1163,7 +1164,11 @@ static int rcar_vin_set_rect(struct soc_camera_device *icd) break; } - iowrite32(ALIGN(cam->out_width, 0x10), priv->base + VNIS_REG); + if (icd->current_fmt->host_fmt->fourcc == V4L2_PIX_FMT_NV16) + vnis = ALIGN(cam->out_width, 0x20); + else + vnis = ALIGN(cam->out_width, 0x10); + iowrite32(vnis, priv->base + VNIS_REG); return 0; } @@ -1605,6 +1610,15 @@ static int rcar_vin_set_fmt(struct soc_camera_device *icd, dev_dbg(dev, "S_FMT(pix=0x%x, %ux%u)\n", pixfmt, pix->width, pix->height); + /* + * At the time of NV16 capture format, the user has to specify the + * width of the multiple of 32 for H/W specification. + */ + if ((pixfmt == V4L2_PIX_FMT_NV16) && (pix->width & 0x1F)) { + dev_err(icd->parent, "Specified width error in NV16 format.\n"); + return -EINVAL; + } + switch (pix->field) { default: pix->field = V4L2_FIELD_NONE;