From patchwork Mon Feb 29 13:12:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 8453861 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 EEA439F65E for ; Mon, 29 Feb 2016 13:14:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 368342013D for ; Mon, 29 Feb 2016 13:14:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CDDE20166 for ; Mon, 29 Feb 2016 13:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753508AbcB2NON (ORCPT ); Mon, 29 Feb 2016 08:14:13 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:36697 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753434AbcB2NOM (ORCPT ); Mon, 29 Feb 2016 08:14:12 -0500 Received: by mail-pf0-f172.google.com with SMTP id t66so26391332pfb.3; Mon, 29 Feb 2016 05:14:11 -0800 (PST) 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=RiXnypi2TM8/iaIU3MusNxgnfWpuYZYetnXfgDM2hjU=; b=VXwMNcSJ1Nza4ugI3s+mn14SCVtpCuk6U6KY4KJqXEpBozSJLrZzTIJkvKA8NvaaQt jHstddtyRv7R//+hUYO38ntEFcXcXanoMru5DDm1dvNxdyycjeIdzDksNGUdHla6a7sn SqA190TVOY0Msz/+sUX9PepOiK238EGC7qVUG3yjF+q9FhbsmJ/MTF7SaoK+Tiq0FXML POfunoxAX8HyXDm5INVGE9dO/0JLHrgpGii8q9GD4rwxMsd66d1uVc1iLKxbMEzgnhEa lDbBbqiNpyWGnwYt3R2qAYBy7XurEeO7bpTGR2lNDco0zh1fKuNkYuLFxKws9xxmlq61 N/og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RiXnypi2TM8/iaIU3MusNxgnfWpuYZYetnXfgDM2hjU=; b=KUPi130rwufL4nDfFv3of8buFLT8gSRZIWs0mb7FVn+sRkrQ8RW48ZRg1NqvwQIThv PCgWeWHFxFIqMyblLFDTdETzFxWOc7uQDmO0v8LRE8tpdT3MiL+wiWepRvpb1tQSSoQs K/DOnL6jJ59gTlCWEaO9O6/p58YNR7grwegZUQoo3zhrY+ifOLBzysFzjGf7wUtaX27m TgriCvPQRlmGgFrvL7PvWDqoLIBBe5WdKkK8bb14bPGAS/9jaXsqEgsw7oR3TNBWclFV jUIQt74rfD0MEu77/54HG9SjTg7HlSR5LR5yEha8ipbmM34pPurFTdWnpG5E4FNq6Hsb epBQ== X-Gm-Message-State: AD7BkJLXJSqdNySGaKtcI673sZyLHhJ/VBhdb166vfHkQi3/OCC5/O/F9LR3zUIdC/VDPg== X-Received: by 10.98.76.194 with SMTP id e63mr21724298pfj.9.1456751650483; Mon, 29 Feb 2016 05:14:10 -0800 (PST) Received: from macc.flets-east.jp (p3469131-ipngn19901marunouchi.tokyo.ocn.ne.jp. [153.229.6.131]) by smtp.gmail.com with ESMTPSA id c9sm38150913pfd.90.2016.02.29.05.14.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 05:14:10 -0800 (PST) From: Yoshihiro Kaneko To: linux-media@vger.kernel.org Cc: Guennadi Liakhovetski , Simon Horman , Magnus Damm , linux-renesas-soc@vger.kernel.org Subject: [PATCH/RFC 4/4] media: soc_camera: rcar_vin: Add NV16 scaling support Date: Mon, 29 Feb 2016 22:12:43 +0900 Message-Id: <1456751563-21246-5-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456751563-21246-1-git-send-email-ykaneko0929@gmail.com> References: <1456751563-21246-1-git-send-email-ykaneko0929@gmail.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 The scaling function had been forbidden for the capture format of NV16 until now. With this patch, a horizontal scaling-up function is supported to the capture format of NV16. This patch adds the check of the capture width for NV16 format, too. 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 ioctl of VIDIOC_S_FMT, this patch adds 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 | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 96f3c8a..979b28c 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -504,6 +504,7 @@ struct rcar_vin_priv { bool request_to_stop; struct completion capture_stop; enum chip_id chip; + bool error_check_flag; }; #define is_continuous_transfer(priv) (priv->vb_count > MAX_BUFFER_NUM) @@ -649,7 +650,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(cam->out_width * cam->out_height, 0x80), priv->base + VNUVAOF_REG); dmr = VNDMR_DTMD_YCSEP; output_is_yuv = true; @@ -961,6 +962,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_check_flag = false; + return 0; } @@ -978,6 +981,7 @@ static void rcar_vin_remove_device(struct soc_camera_device *icd) priv->state = STOPPED; priv->request_to_stop = false; + priv->error_check_flag = false; /* make sure active buffer is cancelled */ spin_lock_irq(&priv->lock); @@ -1166,11 +1170,19 @@ static int rcar_vin_set_rect(struct soc_camera_device *icd) break; } - if (priv->chip == RCAR_GEN3 && is_scaling(cam) { - ret = rcar_vin_uds_set(priv, cam); - if (ret < 0) - return ret; - iowrite32(ALIGN(cam->out_width, 0x20), priv->base + VNIS_REG); + if (priv->chip == RCAR_GEN3) { + if (is_scaling(cam)) { + ret = rcar_vin_uds_set(priv, cam); + if (ret < 0) + return ret; + } + if (is_scaling(cam) || + icd->current_fmt->host_fmt->fourcc == V4L2_PIX_FMT_NV16) + iowrite32(ALIGN(cam->out_width, 0x20), + priv->base + VNIS_REG); + else + iowrite32(ALIGN(cam->out_width, 0x10), + priv->base + VNIS_REG); } else { /* Set scaling coefficient */ value = 0; @@ -1674,6 +1686,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_check_flag == false) { + priv->error_check_flag = true; + } else if (pixfmt == V4L2_PIX_FMT_NV16 && (pix->width & 0x1F)) { + dev_dbg(icd->parent, "specified width error in NV16 format.\n"); + return -EINVAL; + } + switch (pix->field) { default: pix->field = V4L2_FIELD_NONE; @@ -1720,6 +1743,7 @@ static int rcar_vin_set_fmt(struct soc_camera_device *icd, case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_RGB565: case V4L2_PIX_FMT_RGB555X: + case V4L2_PIX_FMT_NV16: can_scale = true; break; default: