From patchwork Tue Oct 14 06:26:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5078121 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 7B076C11AC for ; Tue, 14 Oct 2014 06:27:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9556820127 for ; Tue, 14 Oct 2014 06:27:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 052D120154 for ; Tue, 14 Oct 2014 06:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754419AbaJNG1P (ORCPT ); Tue, 14 Oct 2014 02:27:15 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:53383 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754489AbaJNG1O (ORCPT ); Tue, 14 Oct 2014 02:27:14 -0400 Received: by mail-pd0-f179.google.com with SMTP id r10so6932833pdi.38 for ; Mon, 13 Oct 2014 23:27:14 -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=WCJxRwMTXbgb8iz3oH4+s4LrXGa2EWo1Wgp0HzJL1cQ=; b=ThkINFScVit8NRxIhC6+6/YnIqfSG3Qs6V+3K9y/0BQ1m5+yfhobgWiIjN/8CW9/J6 SSZxuJDmMhMuexFpy7r4kSoNdDhuR6FdRHpZZP4LyksKTtKK4D8Ftr9BlDv+Jan2ufPY 0zsU46ioJ1ZZ64wyuQ0rh6QawiYa91iLu/rfynF+gR9R5CyXOyXr+tSiZBq6K5olF0fA uJDb9hYuTVpgPcCK6iTytiasOy5hQtq6LuIwnevo5T3KUL/NYa93BdlCU0+3S+7lEAjg DgYNqIYJB92aMTTnnwWpmqM4mw9YmRVPDfPWAsQv4teIvQoRHL1AvHnhrMTb+J7YKWOZ pRSw== X-Received: by 10.70.43.233 with SMTP id z9mr3248484pdl.128.1413268033991; Mon, 13 Oct 2014 23:27:13 -0700 (PDT) Received: from localhost.localdomain (p5095-ipngn6701marunouchi.tokyo.ocn.ne.jp. [153.174.4.95]) by mx.google.com with ESMTPSA id nh8sm10324125pdb.25.2014.10.13.23.27.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 23:27:13 -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 2/3] media: soc_camera: rcar_vin: Add capture width check for NV16 format Date: Tue, 14 Oct 2014 15:26:52 +0900 Message-Id: <1413268013-8437-3-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413268013-8437-1-git-send-email-ykaneko0929@gmail.com> References: <1413268013-8437-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=-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=unavailable 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 --- drivers/media/platform/soc_camera/rcar_vin.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 746f03f..00bc98d 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -488,6 +488,7 @@ struct rcar_vin_priv { bool request_to_stop; struct completion capture_stop; enum chip_id chip; + bool error_flag; }; #define is_continuous_transfer(priv) (priv->vb_count > MAX_BUFFER_NUM) @@ -647,7 +648,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; @@ -976,6 +977,8 @@ static int rcar_vin_add_device(struct soc_camera_device *icd) dev_dbg(icd->parent, "R-Car VIN driver attached to camera %d\n", icd->devnum); + priv->error_flag = false; + return 0; } @@ -993,6 +996,7 @@ static void rcar_vin_remove_device(struct soc_camera_device *icd) priv->state = STOPPED; priv->request_to_stop = false; + priv->error_flag = false; /* make sure active buffer is cancelled */ spin_lock_irq(&priv->lock); @@ -1089,6 +1093,7 @@ static int rcar_vin_set_rect(struct soc_camera_device *icd) unsigned char dsize = 0; struct v4l2_rect *cam_subrect = &cam->subrect; unsigned long value; + unsigned long imgstr; dev_dbg(icd->parent, "Crop %ux%u@%u:%u\n", icd->user_width, icd->user_height, cam->vin_left, cam->vin_top); @@ -1166,7 +1171,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) + imgstr = ALIGN(cam->out_width, 0x20); + else + imgstr = ALIGN(cam->out_width, 0x10); + iowrite32(imgstr, priv->base + VNIS_REG); return 0; } @@ -1608,6 +1617,17 @@ 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 (priv->error_flag == false) + priv->error_flag = true; + else { + 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;