From patchwork Thu Apr 6 13:55:29 2017
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 9667533
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
84D4D6021C for ;
Thu, 6 Apr 2017 13:56:46 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EB7727F89
for ;
Thu, 6 Apr 2017 13:56:46 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
id 7337928113; Thu, 6 Apr 2017 13:56:46 +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_SIGNED,
DKIM_VALID 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 ADE0327FA3
for ;
Thu, 6 Apr 2017 13:56:44 +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:Cc:List-Subscribe:List-Help:List-Post:
List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To:
Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description:
Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
List-Owner; bh=Q2C1tHA9v3wV7Ti3HX2ZcvvdSU+2JrR9z78vOJqUxmM=;
b=MyLbPMKxi79inZ
hd9CH200OBPkRWHU7EIdY/kd10M5HgvX6tQpOLJyzwcTZHHe6ixHEdKL7d8LZ6szAr74XcpEAZdBq
FW/VzxMqSKisHQbrr7VYizhPn6QL3ZhcoOyq/bDXI3BMogNZIrW5Ymt7AqHcIsbN0OyabUYexD/fO
zKh7BF5yl3HVJXY/kT41exEG6OPNzlq4O1hZOK3oyHgpqxvq5QXgshnGfG8ydlKK81V7hiRpEn8/B
yyEDZ7YBdJJghZ/zlcJQ5O4UYNtosuPxkuG6D6+jB7iQ+hAhgbrTE3CtcE6JVCEYRhYbliW0oSgiJ
7IaRsEljgW1Lo3VVt08w==;
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 1cw7ty-0006cS-De; Thu, 06 Apr 2017 13:56:42 +0000
Received: from metis.ext.pengutronix.de
([2001:67c:670:201:290:27ff:fe1d:cc33])
by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))
id 1cw7tv-0006ai-4K for linux-arm-kernel@lists.infradead.org;
Thu, 06 Apr 2017 13:56:40 +0000
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.84_2)
(envelope-from )
id 1cw7sv-0007wo-Lx; Thu, 06 Apr 2017 15:55:37 +0200
Message-ID: <1491486929.2392.29.camel@pengutronix.de>
Subject: [PATCH] [media] imx: csi: retain current field order and
colorimetry setting as default
From: Philipp Zabel
To: Steve Longerbeam
Date: Thu, 06 Apr 2017 15:55:29 +0200
In-Reply-To: <1490661656-10318-22-git-send-email-steve_longerbeam@mentor.com>
References: <1490661656-10318-1-git-send-email-steve_longerbeam@mentor.com>
<1490661656-10318-22-git-send-email-steve_longerbeam@mentor.com>
X-Mailer: Evolution 3.12.9-1+b1
Mime-Version: 1.0
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-arm-kernel@lists.infradead.org
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20170406_065639_351992_74A2049F
X-CRM114-Status: GOOD ( 12.50 )
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: mark.rutland@arm.com, andrew-ct.chen@mediatek.com,
minghsiu.tsai@mediatek.com, nick@shmanahar.org,
songjun.wu@microchip.com,
hverkuil@xs4all.nl, Steve Longerbeam ,
pavel@ucw.cz, robert.jarzmik@free.fr, devel@driverdev.osuosl.org,
markus.heiser@darmarIT.de, laurent.pinchart+renesas@ideasonboard.com,
shuah@kernel.org, linux@armlinux.org.uk, geert@linux-m68k.org,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
sakari.ailus@linux.intel.com, arnd@arndb.de, mchehab@kernel.org,
bparrot@ti.com, robh+dt@kernel.org, horms+renesas@verge.net.au,
tiffany.lin@mediatek.com, linux-arm-kernel@lists.infradead.org,
niklas.soderlund+renesas@ragnatech.se, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, jean-christophe.trotin@st.com,
kernel@pengutronix.de, fabio.estevam@nxp.com, shawnguo@kernel.org,
sudipm.mukherjee@gmail.com
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
If the the field order is set to ANY in set_fmt, choose the currently
set field order. If the colorspace is set to DEFAULT, choose the current
colorspace. If any of xfer_func, ycbcr_enc or quantization are set to
DEFAULT, either choose the current setting, or the default setting for the
new colorspace, if non-DEFAULT colorspace was given.
This allows to let field order and colorimetry settings be propagated
from upstream by calling media-ctl on the upstream entity source pad,
and then call media-ctl on the sink pad to manually set the input frame
interval, without changing the already set field order and colorimetry
information.
Signed-off-by: Philipp Zabel
---
This is based on imx-media-staging-md-v14, and it is supposed to allow
configuring the pipeline with media-ctl like this:
1) media-ctl --set-v4l2 "'tc358743 1-000f':0[fmt:UYVY8_1X16/1920x1080]"
2) media-ctl --set-v4l2 "'imx6-mipi-csi2':1[fmt:UYVY8_1X16/1920x108]"
3) media-ctl --set-v4l2 "'ipu1_csi0_mux':2[fmt:UYVY8_1X16/1920x1080]"
4) media-ctl --set-v4l2 "'ipu1_csi0':0[fmt:UYVY8_1X16/1920x1080@1/60]"
5) media-ctl --set-v4l2 "'ipu1_csi0':2[fmt:AYUV32/1920x1080@1/30]"
Without having step 4) overwrite the colorspace and field order set on
'ipu1_csi0':0 by the propagation in step 3).
---
drivers/staging/media/imx/imx-media-csi.c | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index 64dc454f6b371..d94ce1de2bf05 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1325,6 +1325,40 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
csi_try_fmt(priv, sensor, cfg, sdformat, crop, compose, &cc);
fmt = __csi_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
+
+ /* Retain current field setting as default */
+ if (sdformat->format.field == V4L2_FIELD_ANY)
+ sdformat->format.field = fmt->field;
+
+ /* Retain current colorspace setting as default */
+ if (sdformat->format.colorspace == V4L2_COLORSPACE_DEFAULT) {
+ sdformat->format.colorspace = fmt->colorspace;
+ if (sdformat->format.xfer_func == V4L2_XFER_FUNC_DEFAULT)
+ sdformat->format.xfer_func = fmt->xfer_func;
+ if (sdformat->format.ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT)
+ sdformat->format.ycbcr_enc = fmt->ycbcr_enc;
+ if (sdformat->format.quantization == V4L2_QUANTIZATION_DEFAULT)
+ sdformat->format.quantization = fmt->quantization;
+ } else {
+ if (sdformat->format.xfer_func == V4L2_XFER_FUNC_DEFAULT) {
+ sdformat->format.xfer_func =
+ V4L2_MAP_XFER_FUNC_DEFAULT(
+ sdformat->format.colorspace);
+ }
+ if (sdformat->format.ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) {
+ sdformat->format.ycbcr_enc =
+ V4L2_MAP_YCBCR_ENC_DEFAULT(
+ sdformat->format.colorspace);
+ }
+ if (sdformat->format.quantization == V4L2_QUANTIZATION_DEFAULT) {
+ sdformat->format.quantization =
+ V4L2_MAP_QUANTIZATION_DEFAULT(
+ cc->cs != IPUV3_COLORSPACE_YUV,
+ sdformat->format.colorspace,
+ sdformat->format.ycbcr_enc);
+ }
+ }
+
*fmt = sdformat->format;
if (sdformat->pad == CSI_SINK_PAD) {