Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp224573imm; Fri, 5 Oct 2018 02:46:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV62xJadEqGHuO8Xn5Q3PjRhzG93L6bOA4r6jEEX7Zju4nK+2+epOiA5dDfG7/M0r8/5bRe6J X-Received: by 2002:a62:509a:: with SMTP id g26-v6mr10883483pfj.62.1538732784261; Fri, 05 Oct 2018 02:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538732784; cv=none; d=google.com; s=arc-20160816; b=vUEYXrKaejVGkGlUNFpNugq8qZ0zqonfyxRiG0cnEWh0DBqljVZpaqxL8iA2Yp4ZoQ yLkasUAXWe9QLmmMexJVAmHp/22y+93tG+kcgGkUDrF0VE8T7EC1HQu6h/eTs/k1W0oG oklJXr6CWBU/qbn4O7Frn7lb9uMfDoa85uypYYYSlZ38Vz1SslR7NzdvoGW7bFtuspii LrSMqXib1wNs9YMYL+31HMIUSsDW3qGWTlNLDe89Br0/y0iR83LpZvhyg12/iRp0dOdn n5oYCGb5XQ9D97Zd2C26fA7tdDQMdzDSThCBmGIf9etFWJHt6m9JJWKgBFeiNVVU8aiL sCFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=8eOfEX7PbMAas28R4bAuUEkgfHM4in6EP3gdICy/BXc=; b=rRZE2eFrnmFmJTBX+YdQTj8T9MTWRJxS80H6rS/EIXWP5EDbd43ABLwVq4iQrNvFMZ gkSQ9l04Ygrl0JMQnr8p2adpySwIu9Kbrq084scmDeIjHU0Ej3TW81KNWAQyDUEHYvrm h4CNxo8HwFVyOpvwkoUBiAj/zN4fHcvC6w/X5DCreTZQWiw3qDQhVEDHDwfwi1vzyxZ9 VNjDoX+7OWrTb1h6F64yTuCJDuu5KTy/MLpRDndLNCTmQhhbBZDCANrvk4v7ghnpbdxL DWnOFHZSD1tOuGI/hfKfCE4xqYh/xzxpsVtEcwRUfuIDFAtVcU4YN5cY5/kigKQHZldR HUwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5-v6si6837094pgl.343.2018.10.05.02.46.07; Fri, 05 Oct 2018 02:46:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbeJEQmq (ORCPT + 99 others); Fri, 5 Oct 2018 12:42:46 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:40055 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbeJEQmq (ORCPT ); Fri, 5 Oct 2018 12:42:46 -0400 Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1g8Mf4-0004ez-Mr; Fri, 05 Oct 2018 11:44:42 +0200 Message-ID: <1538732679.3545.5.camel@pengutronix.de> Subject: Re: [PATCH v4 02/11] gpu: ipu-csi: Swap fields according to input/output field types From: Philipp Zabel To: Steve Longerbeam , linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , "open list:DRM DRIVERS FOR FREESCALE IMX" , open list , "open list:STAGING SUBSYSTEM" , "open list:FRAMEBUFFER LAYER" Date: Fri, 05 Oct 2018 11:44:39 +0200 In-Reply-To: <20181004185401.15751-3-slongerbeam@gmail.com> References: <20181004185401.15751-1-slongerbeam@gmail.com> <20181004185401.15751-3-slongerbeam@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, On Thu, 2018-10-04 at 11:53 -0700, Steve Longerbeam wrote: [...] > int ipu_csi_init_interface(struct ipu_csi *csi, > struct v4l2_mbus_config *mbus_cfg, > - struct v4l2_mbus_framefmt *mbus_fmt) > + struct v4l2_mbus_framefmt *infmt, > + struct v4l2_mbus_framefmt *outfmt) > { [...] > + std = V4L2_STD_UNKNOWN; > + if (width == 720) { > + switch (height) { > + case 480: > + std = V4L2_STD_NTSC; > + break; > + case 576: > + std = V4L2_STD_PAL; > + break; > + default: > + break; > + } > + } > + > + if (std == V4L2_STD_UNKNOWN) { > dev_err(csi->ipu->dev, [...] > + "Unsupported interlaced video mode\n"); > + ret = -EINVAL; > + goto out_unlock; > } [...] > + > + /* framelines for NTSC / PAL */ > + height = (std & V4L2_STD_525_60) ? 525 : 625; I think this is a bit convoluted. Instead of initializing std, then possibly changing it, and then comparing to the inital value, and then checking it again to determine the new height, why not just: if (width == 720 && height == 480) { std = V4L2_STD_NTSC; height = 525; } else if (width == 720 && height == 576) { std = V4L2_STD_PAL; height = 625; } else { dev_err(csi->ipu->dev, "Unsupported interlaced video mode\n"); ret = -EINVAL; goto out_unlock; } ? > break; > case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: > case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: > @@ -476,9 +529,10 @@ int ipu_csi_init_interface(struct ipu_csi *csi, > dev_dbg(csi->ipu->dev, "CSI_ACT_FRM_SIZE = 0x%08X\n", > ipu_csi_read(csi, CSI_ACT_FRM_SIZE)); > > +out_unlock: > spin_unlock_irqrestore(&csi->lock, flags); > > - return 0; > + return ret; > } > EXPORT_SYMBOL_GPL(ipu_csi_init_interface); > > diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c > index 4acdd7ae612b..ad66f007d395 100644 > --- a/drivers/staging/media/imx/imx-media-csi.c > +++ b/drivers/staging/media/imx/imx-media-csi.c > @@ -666,7 +666,6 @@ static int csi_setup(struct csi_priv *priv) > struct v4l2_mbus_framefmt *infmt, *outfmt; > const struct imx_media_pixfmt *incc; > struct v4l2_mbus_config mbus_cfg; > - struct v4l2_mbus_framefmt if_fmt; > struct v4l2_rect crop; > > infmt = &priv->format_mbus[CSI_SINK_PAD]; > @@ -679,22 +678,14 @@ static int csi_setup(struct csi_priv *priv) > priv->upstream_ep.bus.parallel.flags : > priv->upstream_ep.bus.mipi_csi2.flags; > > - /* > - * we need to pass input frame to CSI interface, but > - * with translated field type from output format > - */ > - if_fmt = *infmt; > - if_fmt.field = outfmt->field; > crop = priv->crop; > > /* > * if cycles is set, we need to handle this over multiple cycles as > * generic/bayer data > */ > - if (is_parallel_bus(&priv->upstream_ep) && incc->cycles) { > - if_fmt.width *= incc->cycles; If the input format width passed to ipu_csi_init_interface is not multiplied by the number of cycles per pixel anymore, width in the CSI_SENS_FRM_SIZE register will be set to the unmultiplied value from infmt. This breaks 779680e2e793 ("media: imx: add support for RGB565_2X8 on parallel bus"). > + if (is_parallel_bus(&priv->upstream_ep) && incc->cycles) > crop.width *= incc->cycles; > - } > > ipu_csi_set_window(priv->csi, &crop); > > @@ -702,7 +693,7 @@ static int csi_setup(struct csi_priv *priv) > priv->crop.width == 2 * priv->compose.width, > priv->crop.height == 2 * priv->compose.height); > > - ipu_csi_init_interface(priv->csi, &mbus_cfg, &if_fmt); > + ipu_csi_init_interface(priv->csi, &mbus_cfg, infmt, outfmt); regards Philipp