From patchwork Thu May 25 00:29:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9747413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EB90601E9 for ; Thu, 25 May 2017 00:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F36F26E47 for ; Thu, 25 May 2017 00:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5333526E98; Thu, 25 May 2017 00:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6C8826E47 for ; Thu, 25 May 2017 00:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=inXGUMEi8QQ3jXb/MgTR6l9yDTooFqdT7igtk5X9VIQ=; b=jvxltH+VQ9y/5plhuhwlyZYfVi j0MMNOuZRJlFPE2ANzkWTDIqeKAyfHOwo0B5rKWp7PrcMIDYpV8ohSouk1TS7cz66xYvY/tehrR/7 dVi+mqvRX52fP8nBOjDBP+BcKyCyVri0SGOoJcYyfl2dCj8mh1Q9Wuztfuu9ka2nNdqcefZa1tG4l SjVp70MqZwOi4slutnS8+WhgNUiajuO2235YdBHajHpNoKQDrOR0Zwh7bu7u4UCmdLXNZSA5qra0T Wbk4l5vf0Af0hv9mwKtM8XkUAveUgwdnaun+iec5sPufLqSz/1tfbg/w8xQxbNlSpmkTs3i513A9g kd2g0qUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDgnK-0007r8-Ub; Thu, 25 May 2017 00:38:26 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dDgn0-0007HD-Tv for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2017 00:38:08 +0000 Received: by mail-pf0-x242.google.com with SMTP id f27so35412036pfe.0 for ; Wed, 24 May 2017 17:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mtcmcShFIoM8m4scWDUTvm6THvBeP64bA/j9LnP02Jg=; b=NMADY1zHJlIgrOIrB3zHjVgk9LcPOSgecLCk3m0NQeF1bOhx3KsOu7ekLUJxC4J0ia Dz1Bj2mot7ZQWFTvi25EeZYB1qdN+XElQNLkqNPyUmTF1Q0jnneoYdqMsrXNT8FZYbO9 +2EsqkEaBK0fnvXEIep5sZqw4ApHt4plB3mnuumJClRc7+cx7PX1dXKUUl4N/1nnZjWm dmvorUAbd/jMyC/QAixGmLTaHD8IVMw815DfbgnD0fiOmtOTB0SrWKRR3GhFgnmI0t3D v4h5m1BQwwEuABvYfMiaS8XVLp/VE+/ElE8Z9xP4p0K7MGeyQANztwG6txOvsacQ5jiQ D0gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mtcmcShFIoM8m4scWDUTvm6THvBeP64bA/j9LnP02Jg=; b=WZJfbkVQv9D9h7nlAvdlfmEg7pULVm95zc3MezshnnxEObUB0Q1EeetBGnm4LFRQ2P QO4DxtqKu2v8wKacoSkewKrH9mddMRbWtV3JG3SJ/vRJZ9xKJ9D49d1q2FNSr7jeXjAl iv5JfqHFjHbiYs4UQ0KHCOwAJ70zqamGfl70oHGY1RQ3y6KTBTjUw3pvHvoQMUX2YaZd MfSRR3BTAuCSZlYALaidSvdd9zx4okMJfJgdMcV+gBA6jNPf07IW+5MJwFoa4aDRTc2B Bq0jq6+3kJAwsWVFl5HGVTRMJG0da3xJxZgMkkXosJfRb4Cs8yaqowrGSFVVYaQFer0m TR+w== X-Gm-Message-State: AODbwcBhikWOb9iwjHDYSI6xF/buVK3GvLSS2zlYrptdEGaZ7aG6KQYk nyp+kiZG4HA6GA== X-Received: by 10.84.237.2 with SMTP id s2mr27447674plk.176.1495672272107; Wed, 24 May 2017 17:31:12 -0700 (PDT) Received: from mappy.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id q27sm10605716pfk.4.2017.05.24.17.31.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 17:31:11 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, linux@armlinux.org.uk, mchehab@kernel.org, hverkuil@xs4all.nl, nick@shmanahar.org, markus.heiser@darmarIT.de, p.zabel@pengutronix.de, laurent.pinchart+renesas@ideasonboard.com, bparrot@ti.com, geert@linux-m68k.org, arnd@arndb.de, sudipm.mukherjee@gmail.com, minghsiu.tsai@mediatek.com, tiffany.lin@mediatek.com, jean-christophe.trotin@st.com, horms+renesas@verge.net.au, niklas.soderlund+renesas@ragnatech.se, robert.jarzmik@free.fr, songjun.wu@microchip.com, andrew-ct.chen@mediatek.com, gregkh@linuxfoundation.org, shuah@kernel.org, sakari.ailus@linux.intel.com, pavel@ucw.cz Subject: [PATCH v7 27/34] media: imx: csi: add support for bayer formats Date: Wed, 24 May 2017 17:29:42 -0700 Message-Id: <1495672189-29164-28-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495672189-29164-1-git-send-email-steve_longerbeam@mentor.com> References: <1495672189-29164-1-git-send-email-steve_longerbeam@mentor.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170524_173807_030556_2650F9F0 X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, Steve Longerbeam , linux-kernel@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King Bayer formats must be treated as generic data and passthrough mode must be used. Add the correct setup for these formats. Signed-off-by: Russell King - added check to csi_link_validate() to verify that destination is IDMAC output pad when passthrough conditions exist: bayer formats and 16-bit parallel buses. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 74 ++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index b9416ea6..7defe53 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -288,10 +288,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) struct imx_media_video_dev *vdev = priv->vdev; struct v4l2_of_endpoint *sensor_ep; struct v4l2_mbus_framefmt *infmt; - unsigned int burst_size; struct ipu_image image; + u32 passthrough_bits; dma_addr_t phys[2]; bool passthrough; + u32 burst_size; int ret; infmt = &priv->format_mbus[CSI_SINK_PAD]; @@ -309,24 +310,52 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) image.phys0 = phys[0]; image.phys1 = phys[1]; - ret = ipu_cpmem_set_image(priv->idmac_ch, &image); - if (ret) - goto unsetup_vb2; - - burst_size = (image.pix.width & 0xf) ? 8 : 16; - - ipu_cpmem_set_burstsize(priv->idmac_ch, burst_size); - /* - * If the sensor uses 16-bit parallel CSI bus, we must handle - * the data internally in the IPU as 16-bit generic, aka - * passthrough mode. + * Check for conditions that require the IPU to handle the + * data internally as generic data, aka passthrough mode: + * - raw bayer formats + * - the sensor bus is 16-bit parallel */ - passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >= 16); + switch (image.pix.pixelformat) { + case V4L2_PIX_FMT_SBGGR8: + case V4L2_PIX_FMT_SGBRG8: + case V4L2_PIX_FMT_SGRBG8: + case V4L2_PIX_FMT_SRGGB8: + burst_size = 8; + passthrough = true; + passthrough_bits = 8; + break; + case V4L2_PIX_FMT_SBGGR16: + case V4L2_PIX_FMT_SGBRG16: + case V4L2_PIX_FMT_SGRBG16: + case V4L2_PIX_FMT_SRGGB16: + burst_size = 4; + passthrough = true; + passthrough_bits = 16; + break; + default: + burst_size = (image.pix.width & 0xf) ? 8 : 16; + passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && + sensor_ep->bus.parallel.bus_width >= 16); + passthrough_bits = 16; + break; + } - if (passthrough) - ipu_cpmem_set_format_passthrough(priv->idmac_ch, 16); + if (passthrough) { + ipu_cpmem_set_resolution(priv->idmac_ch, image.rect.width, + image.rect.height); + ipu_cpmem_set_stride(priv->idmac_ch, image.pix.bytesperline); + ipu_cpmem_set_buffer(priv->idmac_ch, 0, image.phys0); + ipu_cpmem_set_buffer(priv->idmac_ch, 1, image.phys1); + ipu_cpmem_set_format_passthrough(priv->idmac_ch, + passthrough_bits); + } else { + ret = ipu_cpmem_set_image(priv->idmac_ch, &image); + if (ret) + goto unsetup_vb2; + } + + ipu_cpmem_set_burstsize(priv->idmac_ch, burst_size); /* * Set the channel for the direct CSI-->memory via SMFC @@ -823,6 +852,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + const struct imx_media_pixfmt *incc; struct v4l2_of_endpoint *sensor_ep; struct imx_media_subdev *sensor; bool is_csi2; @@ -844,6 +874,16 @@ static int csi_link_validate(struct v4l2_subdev *sd, priv->sensor = sensor; sensor_ep = &priv->sensor->sensor_ep; is_csi2 = (sensor_ep->bus_type == V4L2_MBUS_CSI2); + incc = priv->cc[CSI_SINK_PAD]; + + if (priv->dest != IPU_CSI_DEST_IDMAC && + (incc->bayer || (!is_csi2 && + sensor_ep->bus.parallel.bus_width >= 16))) { + v4l2_err(&priv->sd, + "bayer/16-bit parallel buses must go to IDMAC pad\n"); + ret = -EINVAL; + goto out; + } if (is_csi2) { int vc_num = 0; @@ -868,7 +908,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, /* select either parallel or MIPI-CSI2 as input to CSI */ ipu_set_csi_src_mux(priv->ipu, priv->csi_id, is_csi2); - +out: mutex_unlock(&priv->lock); return ret; }