From patchwork Sat Apr 7 13:05:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10327809 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 7818260365 for ; Sat, 7 Apr 2018 13:05:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65EE529561 for ; Sat, 7 Apr 2018 13:05:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A51929612; Sat, 7 Apr 2018 13:05:20 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 940E1295F0 for ; Sat, 7 Apr 2018 13:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751571AbeDGNFS (ORCPT ); Sat, 7 Apr 2018 09:05:18 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:35148 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbeDGNFS (ORCPT ); Sat, 7 Apr 2018 09:05:18 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40JGy509WBz1qx8s; Sat, 7 Apr 2018 15:05:17 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40JGy500hrz1qqlF; Sat, 7 Apr 2018 15:05:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id QiuKbc1Zy7fz; Sat, 7 Apr 2018 15:05:16 +0200 (CEST) X-Auth-Info: Y7PoTnBMy21e3KpKOcR23Tf7q+qpclBCVa6O1uIh8+U= Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz [86.49.107.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 7 Apr 2018 15:05:15 +0200 (CEST) From: Marek Vasut To: linux-media@vger.kernel.org Cc: Marek Vasut , Philipp Zabel , Steve Longerbeam Subject: [PATCH] media: staging/imx: Handle CSI->VDIC->PRPVF pipeline Date: Sat, 7 Apr 2018 15:05:13 +0200 Message-Id: <20180407130513.24936-1-marex@denx.de> X-Mailer: git-send-email 2.16.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case the PRPVF is not connected directly to CSI, the PRPVF subdev driver won't find the CSI subdev and will not configure the CSI input mux. This is not noticable on the IPU1-CSI0 interface with parallel camera, since the mux is set "correctly" by default and the parallel camera will work just fine. This is however noticable on IPU2-CSI1, where the mux is not set to the correct position by default and the pipeline will fail. Add similar code to what is in PRPVF to VDIC driver, so that the VDIC can locate the CSI subdev and configure the mux correctly if the CSI is connected to the VDIC. Make the PRPVF driver configure the CSI mux only in case it's connected directly to CSI and not in case it is connected to VDIC. Signed-off-by: Marek Vasut Cc: Philipp Zabel Cc: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prp.c | 6 ++---- drivers/staging/media/imx/imx-media-vdic.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prp.c b/drivers/staging/media/imx/imx-ic-prp.c index 98923fc844ce..84fa66dae21a 100644 --- a/drivers/staging/media/imx/imx-ic-prp.c +++ b/drivers/staging/media/imx/imx-ic-prp.c @@ -72,14 +72,12 @@ static inline struct prp_priv *sd_to_priv(struct v4l2_subdev *sd) static int prp_start(struct prp_priv *priv) { struct imx_ic_priv *ic_priv = priv->ic_priv; - bool src_is_vdic; priv->ipu = priv->md->ipu[ic_priv->ipu_id]; /* set IC to receive from CSI or VDI depending on source */ - src_is_vdic = !!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC); - - ipu_set_ic_src_mux(priv->ipu, priv->csi_id, src_is_vdic); + if (!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC)) + ipu_set_ic_src_mux(priv->ipu, priv->csi_id, false); return 0; } diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c index b538bbebedc5..e660911e7024 100644 --- a/drivers/staging/media/imx/imx-media-vdic.c +++ b/drivers/staging/media/imx/imx-media-vdic.c @@ -117,6 +117,9 @@ struct vdic_priv { bool csi_direct; /* using direct CSI->VDIC->IC pipeline */ + /* the CSI id at link validate */ + int csi_id; + /* motion select control */ struct v4l2_ctrl_handler ctrl_hdlr; enum ipu_motion_sel motion; @@ -388,6 +391,9 @@ static int vdic_start(struct vdic_priv *priv) if (ret) return ret; + /* set IC to receive from CSI or VDI depending on source */ + ipu_set_ic_src_mux(priv->ipu, priv->csi_id, true); + /* * init the VDIC. * @@ -778,6 +784,7 @@ static int vdic_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct vdic_priv *priv = v4l2_get_subdevdata(sd); + struct imx_media_subdev *csi; int ret; ret = v4l2_subdev_link_validate_default(sd, link, @@ -785,6 +792,23 @@ static int vdic_link_validate(struct v4l2_subdev *sd, if (ret) return ret; + csi = imx_media_find_upstream_subdev(priv->md, priv->src, + IMX_MEDIA_GRP_ID_CSI); + if (!IS_ERR(csi)) { + switch (csi->sd->grp_id) { + case IMX_MEDIA_GRP_ID_CSI0: + priv->csi_id = 0; + break; + case IMX_MEDIA_GRP_ID_CSI1: + priv->csi_id = 1; + break; + default: + ret = -EINVAL; + } + } else { + priv->csi_id = 0; + } + mutex_lock(&priv->lock); if (priv->csi_direct && priv->motion != HIGH_MOTION) {