From patchwork Wed Aug 1 19:12:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F014C15E9 for ; Wed, 1 Aug 2018 19:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E86B92AC4B for ; Wed, 1 Aug 2018 19:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC7002B8A5; Wed, 1 Aug 2018 19:14:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 881B92AC4B for ; Wed, 1 Aug 2018 19:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732325AbeHAU7v (ORCPT ); Wed, 1 Aug 2018 16:59:51 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33521 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAU7v (ORCPT ); Wed, 1 Aug 2018 16:59:51 -0400 Received: by mail-pl0-f66.google.com with SMTP id 6-v6so9231922plb.0; Wed, 01 Aug 2018 12:12:38 -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=1IHcQjmXg+tga/fo51JEr/xbngVdJl7z6YZpA4lt0Rc=; b=aY0+rE9UfFmwz03QFiUQUhF2Fmag4Gof4E6Bnor1FhF+/IdHUBM83h3+0x64Yahk7c gXfkAxkKNDPI1o+z4/5M3FNl4WLFjTQWgESAv3TdQmKD1++RzRGu5E2mhuWHYVrAGBkG YyTMZ6R+1MSxj/bnOW/aMcZBFyWCpRflFjUvQom/hu/RbPkZyNfLLR5lagc5x/j1pCki bPzxx9yjuUM7TNbU+uSDf8I+KhTlFBUW98XMnKVAWOIQolb/tnf1WNQr97+dpFNDEXFw E5NcfFINXfEPs1g9C9YlUkVurUG5nigRHJudxT6rKxt4Tb9MmBHt5S7+bj73ZVfbgiBp UdbQ== 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=1IHcQjmXg+tga/fo51JEr/xbngVdJl7z6YZpA4lt0Rc=; b=sZ3CAtIv4ac/FcL2QUTe41nHOL6e/U30C3zrR34ypvH6rKZ5JfUPxn8i9OL71izrsN etqfNjbGTlLESsqXqqriLK27hAOuxXFrxaecQIg96GELuT6s2HQpR4jPZ7a4spv9r45Y g7iYtKJDqIP6jEiKKJ+glkiVTMohAHYNLNcHmM+Uq86WNthZiuoY2wb/G/XA/zeoYjer ikA+C5rp7r3pSMVWFHQEb2mX2qbs4UUc95465JY4E6U+g0jMdl6zlnTvcEhZTm/CKcnu hS0Bv071insgPBfQFDC2RRPice0cnwxSNqoDNgbRV9iBDDWmin5izPT3fwu7xeayVk/c Mi8A== X-Gm-Message-State: AOUpUlH0hdRlifX/EHlbV1X45vOp3plVCC5zTBnHjGkN5zCQx0zEJjX+ vdNfs35YIGr4f+gx+k4GofJWvp/0 X-Google-Smtp-Source: AAOMgpdQrETeJ+pjEpj86RqY8HYw/Z2dQiREYTIpep6s1z9gl1Fe1vAhLt/1/ShR8eKEXOkKImFJCg== X-Received: by 2002:a17:902:1121:: with SMTP id d30-v6mr26303365pla.247.1533150757269; Wed, 01 Aug 2018 12:12:37 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:36 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 01/14] media: videodev2.h: Add more field helper macros Date: Wed, 1 Aug 2018 12:12:14 -0700 Message-Id: <1533150747-30677-2-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 Adds two helper macros: V4L2_FIELD_IS_SEQUENTIAL: returns true if the given field type is 'sequential', that is a full frame is transmitted, or exists in memory, as all top field lines followed by all bottom field lines, or vice-versa. V4L2_FIELD_IS_INTERLACED: returns true if the given field type is 'interlaced', that is a full frame is transmitted, or exists in memory, as top field lines interlaced with bottom field lines. Signed-off-by: Steve Longerbeam --- Changes since v2: - none Changes since v1: - add the complement macro V4L2_FIELD_IS_INTERLACED - remove V4L2_FIELD_ALTERNATE from V4L2_FIELD_IS_SEQUENTIAL macro. - moved new macros past end of existing V4L2_FIELD_HAS_* macros. --- include/uapi/linux/videodev2.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index d8b3309..d7007ba 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -130,6 +130,13 @@ enum v4l2_field { ((field) == V4L2_FIELD_BOTTOM ||\ (field) == V4L2_FIELD_TOP ||\ (field) == V4L2_FIELD_ALTERNATE) +#define V4L2_FIELD_IS_INTERLACED(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_INTERLACED_TB ||\ + (field) == V4L2_FIELD_INTERLACED_BT) +#define V4L2_FIELD_IS_SEQUENTIAL(field) \ + ((field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) enum v4l2_buf_type { V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, From patchwork Wed Aug 1 19:12:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2ACF13BF for ; Wed, 1 Aug 2018 19:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB3D92AC4B for ; Wed, 1 Aug 2018 19:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF6732B8A5; Wed, 1 Aug 2018 19:14:07 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 8283F2AC4B for ; Wed, 1 Aug 2018 19:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732358AbeHAU7x (ORCPT ); Wed, 1 Aug 2018 16:59:53 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35667 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAU7x (ORCPT ); Wed, 1 Aug 2018 16:59:53 -0400 Received: by mail-pl0-f65.google.com with SMTP id w3-v6so9232744plq.2; Wed, 01 Aug 2018 12:12:39 -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=pAJbrA/YfR7XZFVIlgPNgmhmafBwE/Gcygtk7HRyCVA=; b=Db15hkmsBTjNalq8a1mRmC2WNBZ3eFO/cX0GSyZSkuq+cG5oXNYv18SNehAAUodHYg nIhbFq7NO8p5RwkXB/57MjB6TSfKmOHTsCRzKQDZnreUgrpNvqgtnlJEEtvVqs/k3dyF g+pO5dZbyjZPP7fCtab2HTWWlcu3y4WFdU4uK6nPjOK4jPAnKm04i/9vw6gZDsU+j2WR K9YB24x+LsBnynboW++jBQCtKvmBvw+2gFzhAGmjpxpO7Fq3Z2DEKTCVLXlzLXgvEzL0 2uxc7cfjOhp48sk1gbttjQeabCH3w5a0T7WryLKBMl1u3lcKD34Rbg8Mbp0A4ed1S2aX wSqA== 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=pAJbrA/YfR7XZFVIlgPNgmhmafBwE/Gcygtk7HRyCVA=; b=GvtjOVy/v/LhK5MjV18gMNU8/goaqcm2//IiWu/vKDX7c7yaJGDX9G4a2M2fTPlhC1 JADG3NVMrj1FU5pZFJdva2equUiaQJM2raHF2eNV+Dqeqv3c2nqai4dwsP53xnb43f1X rfC4LanDjAs2mBMgvzOft65XRvAumn/nEgRfZvZCfyoQgPIa8fpe8vwj2zpvLvKoUq3f 3Jcbni6duRSI0RTalui+hFy6W8n3L/ejE5y6nTEaiVjFifD/3d8Zl0uAKB9p3qXI9gPP 3Sum87Mg7k/NMMvF2hBmlKzdIwXv8JK06CSMmkYZlrFdZ7B+1ONaieANHgX47luXDKWS HCQA== X-Gm-Message-State: AOUpUlEPo+X2V4fkrv+CleUouOvSYGbj0SldrHqzAuSt7TkiGN3AahNw iVYPI591Y2w7yaCtaQyqaMm5A1Bi X-Google-Smtp-Source: AAOMgpdNDMNz7bN3uxK9RLcLHv+oxIpomXuwYcUoU5YAG+ob94Rx5sxtVarot8nR1UtrGeAFqrjN6A== X-Received: by 2002:a17:902:3a5:: with SMTP id d34-v6mr2529338pld.98.1533150758942; Wed, 01 Aug 2018 12:12:38 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:38 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate Date: Wed, 1 Aug 2018 12:12:15 -0700 Message-Id: <1533150747-30677-3-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 When the CSI is receiving from a bt.656 bus, include a check for field type 'alternate' when determining whether to set CSI clock mode to CCIR656_INTERLACED or CCIR656_PROGRESSIVE. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-csi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index caa05b0..5450a2d 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -339,7 +339,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, break; case V4L2_MBUS_BT656: csicfg->ext_vsync = 0; - if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field)) + if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) || + mbus_fmt->field == V4L2_FIELD_ALTERNATE) csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED; else csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE; From patchwork Wed Aug 1 19:12:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08B8215E9 for ; Wed, 1 Aug 2018 19:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F40442AC4B for ; Wed, 1 Aug 2018 19:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E87562B8E4; Wed, 1 Aug 2018 19:14:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 247542AC4B for ; Wed, 1 Aug 2018 19:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387503AbeHAU7z (ORCPT ); Wed, 1 Aug 2018 16:59:55 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37085 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAU7z (ORCPT ); Wed, 1 Aug 2018 16:59:55 -0400 Received: by mail-pl0-f68.google.com with SMTP id d5-v6so3693448pll.4; Wed, 01 Aug 2018 12:12:41 -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=OiUro2B3BRRZ6D643C/2qbSbOYXQHcAEAEDDowVOglw=; b=eromNUflktyNVqQHgtN3T5J4NVVKjR1CxySVCCwVeuxaV6vwoLH9J1H3JaD0zkHUG7 vu3K7Nx+qnG1swUdsLqWfFqfVsv5NiCt1IxfZwnNhgaABuiEIDf2diUX/MhU6C+ZoS5g hhKkxe6bZa5QNSSVjSUKKQBLVy1RrT+Np40IQqEnWMxJ/WY0Cthghbu8FmEOg/DwGctZ PMT30yUSA6RKWX3WTHl4crA0a2W7jIfJeLzHlzqzXhQSrFlaryre1jsIZg4890a/1/UZ n1Wax1jrmfQKzfNal1iGhj/cB4QPdQs5CNhfSK1cj0c1GxNIJeLgx8UFucGivYlleppT j99Q== 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=OiUro2B3BRRZ6D643C/2qbSbOYXQHcAEAEDDowVOglw=; b=EjEVo24m6tUWONsYbY2o+NVJLFMcYMO+gPh9gkhmV6trEftGSvSDO5NOzqwmkByU8I gHKtYjRrIi0xjweFOltHpAFwg1+FVnC7AJCKVBEnknbSEh5rPUDkhaWSLCbpGXJ1K6IH MlCSmRQJHNl8KeJy+ZUTqO1gW8Ovnd3aQQJaCEbUfqrB1sqs91RfblbQ+2kwAxFpELEq JpHjNxDiMa5RWY6uPL7fwFvg7Z3DjTTOTTvdKWC2LgT0PRu0czcE17oO39ZiPrrdHKRG XI2obzWikEI74eFbegQb7PfcfsGJkFvr1kgXlJKZMqpiD2wTmUmEdS3rHOlUh3UF2VH0 PI6A== X-Gm-Message-State: AOUpUlF76k1uLFPbeOLdB5JEaX0Zkmfd6xIDDV2WVSE9OVIeO5OO498Z nlYIp3B8UsniN3RZALPUZCRk4Ts/ X-Google-Smtp-Source: AAOMgpcRrpjVXrhOWKHyVHHz8Yt1FPzHX965imzXQwLc8SUtaMCt0QPUkAxBMQpEwonvP4rKdziPJQ== X-Received: by 2002:a17:902:8a92:: with SMTP id p18-v6mr26111869plo.148.1533150760914; Wed, 01 Aug 2018 12:12:40 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:40 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-fbdev@vger.kernel.org (open list:FRAMEBUFFER LAYER) Subject: [PATCH v3 03/14] gpu: ipu-csi: Swap fields according to input/output field types Date: Wed, 1 Aug 2018 12:12:16 -0700 Message-Id: <1533150747-30677-4-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 The function ipu_csi_init_interface() was inverting the F-bit for NTSC case, in the CCIR_CODE_1/2 registers. The result being that for NTSC bottom-top field order, the CSI would swap fields and capture in top-bottom order. Instead, base field swap on the field order of the input to the CSI, and the field order of the requested output. If the input/output fields are sequential but different, swap fields, otherwise do not swap. This requires passing both the input and output mbus frame formats to ipu_csi_init_interface(). Move this code to a new private function ipu_csi_set_bt_interlaced_codes() that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and possibly interlaced BT.1120 in the future). When detecting input video standard from the input frame width/height, make sure to double height if input field type is alternate, since in that case input height only includes lines for one field. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-csi.c | 133 +++++++++++++++++++++--------- drivers/staging/media/imx/imx-media-csi.c | 13 +-- include/video/imx-ipu-v3.h | 3 +- 3 files changed, 98 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index 5450a2d..7a845c9 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -315,6 +315,15 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code) return 0; } +/* translate alternate field mode based on given standard */ +static inline enum v4l2_field +ipu_csi_translate_field(enum v4l2_field field, v4l2_std_id std) +{ + return (field != V4L2_FIELD_ALTERNATE) ? field : + ((std & V4L2_STD_525_60) ? + V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB); +} + /* * Fill a CSI bus config struct from mbus_config and mbus_framefmt. */ @@ -358,19 +367,73 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, } } +static int ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi, + struct v4l2_mbus_framefmt *infmt, + struct v4l2_mbus_framefmt *outfmt, + v4l2_std_id std) +{ + enum v4l2_field infield, outfield; + bool swap_fields; + + /* get translated field type of input and output */ + infield = ipu_csi_translate_field(infmt->field, std); + outfield = ipu_csi_translate_field(outfmt->field, std); + + /* + * Write the H-V-F codes the CSI will match against the + * incoming data for start/end of active and blanking + * field intervals. If input and output field types are + * sequential but not the same (one is SEQ_BT and the other + * is SEQ_TB), swap the F-bit so that the CSI will capture + * field 1 lines before field 0 lines. + */ + swap_fields = (V4L2_FIELD_IS_SEQUENTIAL(infield) && + V4L2_FIELD_IS_SEQUENTIAL(outfield) && + infield != outfield); + + if (!swap_fields) { + /* + * Field0BlankEnd = 110, Field0BlankStart = 010 + * Field0ActiveEnd = 100, Field0ActiveStart = 000 + * Field1BlankEnd = 111, Field1BlankStart = 011 + * Field1ActiveEnd = 101, Field1ActiveStart = 001 + */ + ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN, + CSI_CCIR_CODE_1); + ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2); + } else { + dev_dbg(csi->ipu->dev, "capture field swap\n"); + + /* same as above but with F-bit inverted */ + ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN, + CSI_CCIR_CODE_1); + ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2); + } + + ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); + + return 0; +} + + 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) { struct ipu_csi_bus_config cfg; unsigned long flags; u32 width, height, data = 0; + v4l2_std_id std; + int ret = 0; - fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + fill_csi_bus_cfg(&cfg, mbus_cfg, infmt); /* set default sensor frame width and height */ - width = mbus_fmt->width; - height = mbus_fmt->height; + width = infmt->width; + height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + height *= 2; /* Set the CSI_SENS_CONF register remaining fields */ data |= cfg.data_width << CSI_SENS_CONF_DATA_WIDTH_SHIFT | @@ -397,42 +460,33 @@ int ipu_csi_init_interface(struct ipu_csi *csi, ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); break; case IPU_CSI_CLK_MODE_CCIR656_INTERLACED: - if (mbus_fmt->width == 720 && mbus_fmt->height == 576) { - /* - * PAL case - * - * Field0BlankEnd = 0x6, Field0BlankStart = 0x2, - * Field0ActiveEnd = 0x4, Field0ActiveStart = 0 - * Field1BlankEnd = 0x7, Field1BlankStart = 0x3, - * Field1ActiveEnd = 0x5, Field1ActiveStart = 0x1 - */ - height = 625; /* framelines for PAL */ - - ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN, - CSI_CCIR_CODE_1); - ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2); - ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); - } else if (mbus_fmt->width == 720 && mbus_fmt->height == 480) { - /* - * NTSC case - * - * Field0BlankEnd = 0x7, Field0BlankStart = 0x3, - * Field0ActiveEnd = 0x5, Field0ActiveStart = 0x1 - * Field1BlankEnd = 0x6, Field1BlankStart = 0x2, - * Field1ActiveEnd = 0x4, Field1ActiveStart = 0 - */ - height = 525; /* framelines for NTSC */ - - ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN, - CSI_CCIR_CODE_1); - ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2); - ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); - } else { + 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 CCIR656 interlaced video mode\n"); - spin_unlock_irqrestore(&csi->lock, flags); - return -EINVAL; + "Unsupported interlaced video mode\n"); + ret = -EINVAL; + goto out_unlock; } + + ret = ipu_csi_set_bt_interlaced_codes(csi, infmt, outfmt, std); + if (ret) + goto out_unlock; + + /* framelines for NTSC / PAL */ + height = (std & V4L2_STD_525_60) ? 525 : 625; break; case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: @@ -457,9 +511,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 4647206..2fdd21d 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -663,7 +663,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]; @@ -676,22 +675,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 (is_parallel_bus(&priv->upstream_ep) && incc->cycles) crop.width *= incc->cycles; - } ipu_csi_set_window(priv->csi, &crop); @@ -699,7 +690,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); ipu_csi_set_dest(priv->csi, priv->dest); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index abbad94..f44a351 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -352,7 +352,8 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan, struct ipu_csi; 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); bool ipu_csi_is_interlaced(struct ipu_csi *csi); void ipu_csi_get_window(struct ipu_csi *csi, struct v4l2_rect *w); void ipu_csi_set_window(struct ipu_csi *csi, struct v4l2_rect *w); From patchwork Wed Aug 1 19:12:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B91415E9 for ; Wed, 1 Aug 2018 19:13:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 251572AC4B for ; Wed, 1 Aug 2018 19:13:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 197342B8A5; Wed, 1 Aug 2018 19:13:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 B47C22AC4B for ; Wed, 1 Aug 2018 19:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387611AbeHAU75 (ORCPT ); Wed, 1 Aug 2018 16:59:57 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36307 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAU75 (ORCPT ); Wed, 1 Aug 2018 16:59:57 -0400 Received: by mail-pl0-f66.google.com with SMTP id e11-v6so9233310plb.3; Wed, 01 Aug 2018 12:12:43 -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=2bcAVrZoQ7gAipHE91JvHi55mUc8nI6vJrJeUPIxQl8=; b=Oe9i77Or2we4nkTOI3QlSylkILSQlRmtsyZu3/zMwWeRc4qRb7jSwYYStwR39m89Fn MppvoeG+v2N1GHkm+z3owZLboiSVuSzxuQ1MFhFipaTle2Z/fphNwRtXPo5vNbvU5zwt ze+HludXA9g3oTqXqZ7wpaWhlhAtjNYPhRCGXAMVVtPBxhYmBSXZ0kcaG0kHfOowmgVU q6dZLHNGotICdZ6gwQ1AKd60aBHXeOCmgXYiEVCWq+60Rfdc4iDKWpDDF7MjruilqDmU UljkZV/658foI2l0JKpMuQljBQ+Fpu2VOvPOiesE0Bxa2SzWO/Lg6vYCKcpbEo7y4Jk+ biAg== 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=2bcAVrZoQ7gAipHE91JvHi55mUc8nI6vJrJeUPIxQl8=; b=nH9sl+qLeaC+snXelEeVve8C5PYIw8Ar0iVZhEiID+pmRpWN7u1C6CarkBznsGcBiW 2iy4a978Bfegco/qzH/Cgi6FtT9OhlvQDCmubud86uQHd4S6tevuP+EeUaXSzLUb7faE 0Kcl4/SiOR+hT2mDKmttgOh6l2dW7f0pjx81RUr1ZMmCQjbpM12Eh1qC9/UkAoWXBqIU x6/Cb3CMOFJ9+xK2imzkFRuM4tOhowbNqP1ntE0fUg6i+e91oSGWfd2jc1/4Jhu91LXR QeKuWVnEI7nio09RiDbGgrTVLy/6CfJubhRAfSel1c+FzqN92vzbdVP9dCsjl0q3aQYk hKlA== X-Gm-Message-State: AOUpUlHyxgvbavXzTgppvDFl5orJRdKDeDF90WlteJKxu+zlsbTo7bJn aADwK+Txo2vicjouP/Mkyfg2GWbh X-Google-Smtp-Source: AAOMgpcrUv1K1RlUs4gBNFom7IamXDbBx7bYx707mtmVDm6cx3rGiIBqcQuYlUdT3U3tn6UBsgQYHA== X-Received: by 2002:a17:902:7793:: with SMTP id o19-v6mr26412193pll.306.1533150762593; Wed, 01 Aug 2018 12:12:42 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:41 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0 Date: Wed, 1 Aug 2018 12:12:17 -0700 Message-Id: <1533150747-30677-5-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 The U and V offset macros for planar 4:2:0 (U_OFFSET, V_OFFSET, and UV_OFFSET), are not correct. The height component to the offset was calculated as: (pix->width * y / 4) But this does not produce correct offsets for odd values of y (luma line #). The luma line # must be decimated by two to produce the correct U/V line #, so the correct formula is: (pix->width * (y / 2) / 2) Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-cpmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c index 9f2d9ec..e68e473 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c @@ -530,17 +530,17 @@ static const struct ipu_rgb def_bgra_16 = { #define Y_OFFSET(pix, x, y) ((x) + pix->width * (y)) #define U_OFFSET(pix, x, y) ((pix->width * pix->height) + \ - (pix->width * (y) / 4) + (x) / 2) + (pix->width * ((y) / 2) / 2) + (x) / 2) #define V_OFFSET(pix, x, y) ((pix->width * pix->height) + \ (pix->width * pix->height / 4) + \ - (pix->width * (y) / 4) + (x) / 2) + (pix->width * ((y) / 2) / 2) + (x) / 2) #define U2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ (pix->width * (y) / 2) + (x) / 2) #define V2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ (pix->width * pix->height / 2) + \ (pix->width * (y) / 2) + (x) / 2) #define UV_OFFSET(pix, x, y) ((pix->width * pix->height) + \ - (pix->width * (y) / 2) + (x)) + (pix->width * ((y) / 2)) + (x)) #define UV2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ (pix->width * y) + (x)) From patchwork Wed Aug 1 19:12:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F11713BF for ; Wed, 1 Aug 2018 19:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2884C2AC4B for ; Wed, 1 Aug 2018 19:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CD462B8A5; Wed, 1 Aug 2018 19:13:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 40CDC2AC4B for ; Wed, 1 Aug 2018 19:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387679AbeHAVAA (ORCPT ); Wed, 1 Aug 2018 17:00:00 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37089 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAU76 (ORCPT ); Wed, 1 Aug 2018 16:59:58 -0400 Received: by mail-pl0-f68.google.com with SMTP id d5-v6so3693498pll.4; Wed, 01 Aug 2018 12:12:44 -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=4XgQr0v93BmMi0+ykyaOvN9BFSFtuq3EFayKXlWi74s=; b=bEa93Ifb9Faj5Wl5K9X/HWUc334Za9fdns9J+zj68XBgCqCcWzrNyIbLvoW7/b6XPY JOUiQYnhDmM3V6Do0Qnjn9eJLZQljDWVC7QwhkbAGg+q0vuWLrcMDp7Ucgr1X9+3Q7SZ 9jtVYflW4bBP2z3AW17squlhZ/eF4NIr4+xX9rDT8ot6/0X4m4PtI2W68t0tUQxlqcqM C4R+Oz/zoPcG9BvodU8mUEgLwPdXuzeJB2+8ALzmzCCNxCGc9oxr2vo7e53v1Nmom1uF Ixu4ykgPKDbPm2JrXJ0wPPuz8uRQKuxw5XxqN5w+8jGhx84J3e4TCCc16kvuk4vm7hkR kBNg== 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=4XgQr0v93BmMi0+ykyaOvN9BFSFtuq3EFayKXlWi74s=; b=uROCv0y8WWH/m2OqNjNTNGP+tB8Ne8x+Kckos/4bk1Kedjf90sm7PXDMTYvN4sgqDr HzvYCV6vi0yygUm1YQn+wV8nNeqvFnPFxHijNT/0eJWj53/qv+m0t2ug5yUgIXqwVM8h suF6koRrZ9FOLHjaABBTPJmeEn23apVnG1SCDCzQC5g3QR45ncTLr/jxJBaMM+cCUmft Hf2yHGY+5oPi0c7GvDLVWayFmCgVOrTkvN9hPn5VSJLOpolplBGOh+xC000oHIqUVLzi XzfQsfgnEpwORBNaQjhoivwD25y8HAYhDB750gjWIeXTWG/tJ/3helQen6FcvU3FTm5S CzXg== X-Gm-Message-State: AOUpUlF4Bt3UwkoONskcxCCpvlFrT9ZrEZsdify7lvy/UhEkK86o7P6T tqsvw/R//LgacGE4Isy7LTKdX6fP X-Google-Smtp-Source: AAOMgpcwUV9Ax8YPbRajmczg2HWz0QG47JI0B/UG0xc3IEQ1bFL3q4HiFjgn91uBBClkH3xwC/k6pg== X-Received: by 2002:a17:902:bd82:: with SMTP id q2-v6mr9484396pls.178.1533150764185; Wed, 01 Aug 2018 12:12:44 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:43 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Philipp Zabel , Steve Longerbeam , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning Date: Wed, 1 Aug 2018 12:12:18 -0700 Message-Id: <1533150747-30677-6-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 From: Philipp Zabel The IPU also supports interlaced buffers that start with the bottom field. To achieve this, the the base address EBA has to be increased by a stride length and the interlace offset ILO has to be set to the negative stride. Signed-off-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-cpmem.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c index e68e473..8cd9e37 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c @@ -269,9 +269,20 @@ EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset); void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride) { + u32 ilo, sly; + + if (stride < 0) { + stride = -stride; + ilo = 0x100000 - (stride / 8); + } else { + ilo = stride / 8; + } + + sly = (stride * 2) - 1; + ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1); - ipu_ch_param_write_field(ch, IPU_FIELD_ILO, stride / 8); - ipu_ch_param_write_field(ch, IPU_FIELD_SLY, (stride * 2) - 1); + ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo); + ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly); }; EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan); From patchwork Wed Aug 1 19:12:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E78FA15E9 for ; Wed, 1 Aug 2018 19:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEAD22AC4B for ; Wed, 1 Aug 2018 19:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D180F2B8A5; Wed, 1 Aug 2018 19:13:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 546852AC4B for ; Wed, 1 Aug 2018 19:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388611AbeHAVBA (ORCPT ); Wed, 1 Aug 2018 17:01:00 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36023 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387668AbeHAVAA (ORCPT ); Wed, 1 Aug 2018 17:00:00 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so3157634pfo.3; Wed, 01 Aug 2018 12:12:46 -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=lfq9Nv984HkcP7oUkGd2GXSTmizO1ISnyBumKhQAggs=; b=lK1Xp75+h3F9r4dOb+8BMefNtmb+fka7NPcaLwGtN5Rwq1W7pVbUeifOU/fMAlsiRX OkVk69o3JYqVhKKVvQ0Zmv5JZqhnu8rA/WZEhC/+sTzyFDOgnxtj1bady1xa+VTIATjZ rjQxM8n0DECunGJ1iyrmwFFtoCBbx3HYEBzJ2cz3OXWT3tGBLnPmjtFSp/OZVIvbViTV CJ5uelGDvpU/UL3KdDtnsKCu+b1HIZUnhZ7ef2iM5LHsoR7qRNhpkAtFUdI/CCFyNAHM qbZy/ZVryTI16iyJ6jTr9wxFo4zO/BBWuVTiq65DUfXWIoiznninLXgJ78K9y4D5dlMh JWGw== 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=lfq9Nv984HkcP7oUkGd2GXSTmizO1ISnyBumKhQAggs=; b=YxORYQfgIhUHfRUkApP2nVZtLEWn9bwaEHs7bZG5G94mmEMCx6q9rTvqhrH6Knwqla f+86PmvYzteGb2pngSa+uv4+F6WziPE8MqsSlTqOo4OddVDyAOKFZl23j5HwJ46KStP7 oMibPSGid0DXC2kCDod6Qpw+FkrXA7EY/0ePmjm2qXfbyPEsSYnd4sEbfnA+vyObMEXi p5eUaLOP1GOK6PZ8nPYNtpMfNcwaQ1aTMRbpKJ7ZbEXKz4nmdze+y9obAY8nAwEEm1lI DcM8M7q2Ls3iAcJyiofcmowygZK37UYrsl60vKqObVdGRWymOv1GZf3SwJrk6ZLDlIE7 AN/Q== X-Gm-Message-State: AOUpUlFJ47qSOA/qhNHIikR5yAUfilHlVZwxezHeH9eNHyh0Ne5HdbaH 2xYD/IxzlYFvJ03R+0JTFx/pjSzx X-Google-Smtp-Source: AAOMgpettd0THUKJjWtYHFdIoRTGosLJZZTWv7HcwqEJZK0LCxW+HMDAIGcWqum1TF9fkhVflU4tfQ== X-Received: by 2002:a63:ab0c:: with SMTP id p12-v6mr25533298pgf.190.1533150766028; Wed, 01 Aug 2018 12:12:46 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:45 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-fbdev@vger.kernel.org (open list:FRAMEBUFFER LAYER) Subject: [PATCH v3 06/14] gpu: ipu-v3: Add planar support to interlaced scan Date: Wed, 1 Aug 2018 12:12:19 -0700 Message-Id: <1533150747-30677-7-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 To support interlaced scan with planar formats, cpmem SLUV must be programmed with the correct chroma line stride. For full and partial planar 4:2:2 (YUV422P, NV16), chroma line stride must be doubled. For full and partial planar 4:2:0 (YUV420, YVU420, NV12), chroma line stride must _not_ be doubled, since a single chroma line is shared by two luma lines. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-cpmem.c | 26 ++++++++++++++++++++++++-- drivers/staging/media/imx/imx-ic-prpencvf.c | 3 ++- drivers/staging/media/imx/imx-media-csi.c | 3 ++- include/video/imx-ipu-v3.h | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c index 8cd9e37..eae0f63 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c @@ -267,9 +267,10 @@ void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off) } EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset); -void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride) +void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride, + u32 pixelformat) { - u32 ilo, sly; + u32 ilo, sly, sluv; if (stride < 0) { stride = -stride; @@ -280,9 +281,30 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride) sly = (stride * 2) - 1; + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + sluv = stride / 2 - 1; + break; + case V4L2_PIX_FMT_NV12: + sluv = stride - 1; + break; + case V4L2_PIX_FMT_YUV422P: + sluv = stride - 1; + break; + case V4L2_PIX_FMT_NV16: + sluv = stride * 2 - 1; + break; + default: + sluv = 0; + break; + } + ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1); ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo); ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly); + if (sluv) + ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, sluv); }; EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan); diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 28f41ca..af72248 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -412,7 +412,8 @@ static int prp_setup_channel(struct prp_priv *priv, if (image.pix.field == V4L2_FIELD_NONE && V4L2_FIELD_HAS_BOTH(infmt->field) && channel == priv->out_ch) - ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline); + ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, + image.pix.pixelformat); ret = ipu_ic_task_idma_init(priv->ic, channel, image.pix.width, image.pix.height, diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 2fdd21d..1c468ec 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -509,7 +509,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) if (image.pix.field == V4L2_FIELD_NONE && V4L2_FIELD_HAS_BOTH(infmt->field)) ipu_cpmem_interlaced_scan(priv->idmac_ch, - image.pix.bytesperline); + image.pix.bytesperline, + image.pix.pixelformat); ipu_idmac_set_double_buffer(priv->idmac_ch, true); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index f44a351..e888c66 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -255,7 +255,8 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride); void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch); void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf); void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off); -void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride); +void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride, + u32 pixelformat); void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id); int ipu_cpmem_get_burstsize(struct ipuv3_channel *ch); void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize); From patchwork Wed Aug 1 19:12:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F18CB13BF for ; Wed, 1 Aug 2018 19:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9EC42AC4B for ; Wed, 1 Aug 2018 19:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD5542B8A5; Wed, 1 Aug 2018 19:13:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 228D22AC4B for ; Wed, 1 Aug 2018 19:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387726AbeHAVAD (ORCPT ); Wed, 1 Aug 2018 17:00:03 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40977 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeHAVAC (ORCPT ); Wed, 1 Aug 2018 17:00:02 -0400 Received: by mail-pg1-f193.google.com with SMTP id z8-v6so11277466pgu.8; Wed, 01 Aug 2018 12:12:48 -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=ET+33HCBjiNGHEqkdCh/P5V/V5PyHU9loqp/gnJI+qo=; b=ZEkZT7FPnjVgJzJBHAZTbqEOmvVFebR4i6tfBBXarBL6hbpMsXqKjCfpEtiG1poX4M 8O2NhyN6q1q7COeB8InR6cKhnWAp+XiiDdCY2FWeWxs8zefwYpYGWvtvbZ1tezzz51dw 0kR+rdaXyuCsRF55s/0LpjGOqVe/pGFwKf/P6c2i6ARy14BZeL413IxPLNtlmmjJr8j2 QmVKxWWO7SMm9izpRhEDwhK5Gc3xkC4cNQbgqFjHl1uEj/oqD5xgBmj9wjV9JnbVmD2B SejeQew92t9sFJUNOTn9v3NCRIuUbXtSThPsvKrM6cgd3Y6mzR0kgEG/CmLqt/to/A2a doNA== 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=ET+33HCBjiNGHEqkdCh/P5V/V5PyHU9loqp/gnJI+qo=; b=ti+ohKiNW4k5C04QGTfGdzq5fwbVd3sW5JuU8vNVke8i5PKitZKIzualI0qzuUp69M zdM9+xgJaFOq9KGZTwkcS/iD2ZBEHtIba89YfXBUAKU92nA5dGqM5SFsoIXvB3mMfTY5 yc8VzwY22mrIlyuOWbmkDEIa4Iik0VPgG946gUjsW38+ahGZjct4tThLXEBqClNoe9nO R0Gj68N74fnwEHVad7v2hMY16p5IClZVWhPTJgO/w9n/1n/Y997zK3thHR1l+Y81/+dA S+JRZuKKdCOCKLgWg4bXI/hFAokBUeTXc1VF0Lf22Hgr5Mkn7WUJmxZGM9UeSGhqNmqR jcAw== X-Gm-Message-State: AOUpUlFvAboT1Fxl3WR0uG7A4u0EIKXMe4tBQra4RVGnVr+BzF+2ypi6 oQQJhVvmmWmE/BlIDXV6mDTJy+X/ X-Google-Smtp-Source: AAOMgpeuRm2+IKsM/cY10d9gZt/sSHiybs47HIaVb0lTGCmyELDyemcF4Nva0YLu0SOlmn4Y+KIzrA== X-Received: by 2002:a63:9802:: with SMTP id q2-v6mr25673684pgd.70.1533150767802; Wed, 01 Aug 2018 12:12:47 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:46 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 07/14] media: imx: Fix field negotiation Date: Wed, 1 Aug 2018 12:12:20 -0700 Message-Id: <1533150747-30677-8-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 IDMAC interlaced scan, a.k.a. interweave, should be enabled in the IDMAC output channels only if the IDMAC output pad field type is 'seq-bt' or 'seq-tb', and field type at the capture interface is 'interlaced*'. V4L2_FIELD_HAS_BOTH() macro should not be used on the input to determine enabling interlaced/interweave scan. That macro includes the 'interlaced' field types, and in those cases the data is already interweaved with top/bottom field lines. The CSI will capture whole frames when the source specifies alternate field mode. So the CSI also enables interweave for alternate input field type and the field type at capture interface is interlaced. Fix the logic for setting field type in try_fmt in CSI entity. The behavior should be: - No restrictions on field type at sink pad. - At the output pads, allow sequential fields in TB order, if the sink pad field type is sequential or alternate. Otherwise passthrough the field type from sink to source pad. Move this logic to new function csi_try_field(). These changes result in the following allowed field transformations from CSI sink -> source pads (all other field types at sink are passed through to source): seq-tb -> seq-tb seq-bt -> seq-tb alternate -> seq-tb In a future patch, the CSI sink -> source will allow: seq-tb -> seq-bt seq-bt -> seq-bt alternate -> seq-bt This will require supporting interweave with top/bottom line swapping. Until then seq-bt is not allowed at the CSI source pad because there is no way to swap top/bottom lines when interweaving to INTERLACED_BT -- note that despite the name, INTERLACED_BT is top-bottom order in memory. The BT in this case refers to field dominance: the bottom lines are older in time than the top lines. The capture interface device allows selecting IDMAC interweave by choosing INTERLACED_TB if the CSI/PRPENCVF source pad is seq-tb and INTERLACED_BT if the source pad is seq-bt (for future support of seq-bt). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prpencvf.c | 21 ++++++--- drivers/staging/media/imx/imx-media-capture.c | 14 ++++++ drivers/staging/media/imx/imx-media-csi.c | 64 ++++++++++++++++++++------- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index af72248..1a03d4c 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -354,12 +354,13 @@ static int prp_setup_channel(struct prp_priv *priv, { struct imx_media_video_dev *vdev = priv->vdev; const struct imx_media_pixfmt *outcc; - struct v4l2_mbus_framefmt *infmt; + struct v4l2_mbus_framefmt *outfmt; unsigned int burst_size; struct ipu_image image; + bool interweave; int ret; - infmt = &priv->format_mbus[PRPENCVF_SINK_PAD]; + outfmt = &priv->format_mbus[PRPENCVF_SRC_PAD]; outcc = vdev->cc; ipu_cpmem_zero(channel); @@ -369,6 +370,15 @@ static int prp_setup_channel(struct prp_priv *priv, image.rect.width = image.pix.width; image.rect.height = image.pix.height; + /* + * If the field type at capture interface is interlaced, and + * the output IDMAC pad is sequential, enable interweave at + * the IDMAC output channel. + */ + interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) && + channel == priv->out_ch; + if (rot_swap_width_height) { swap(image.pix.width, image.pix.height); swap(image.rect.width, image.rect.height); @@ -409,9 +419,7 @@ static int prp_setup_channel(struct prp_priv *priv, if (rot_mode) ipu_cpmem_set_rotation(channel, rot_mode); - if (image.pix.field == V4L2_FIELD_NONE && - V4L2_FIELD_HAS_BOTH(infmt->field) && - channel == priv->out_ch) + if (interweave) ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, image.pix.pixelformat); @@ -839,8 +847,7 @@ static void prp_try_fmt(struct prp_priv *priv, infmt = __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD, sdformat->which); if (sdformat->pad == PRPENCVF_SRC_PAD) { - if (sdformat->format.field != V4L2_FIELD_NONE) - sdformat->format.field = infmt->field; + sdformat->format.field = infmt->field; prp_bound_align_output(&sdformat->format, infmt, priv->rot_mode); diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 256039c..5d3dc92 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -239,6 +239,20 @@ static int capture_try_fmt_vid_cap(struct file *file, void *fh, cc = cc_src; } + /* allow IDMAC interweave but enforce field order from source */ + if (V4L2_FIELD_IS_INTERLACED(f->fmt.pix.field)) { + switch (fmt_src.format.field) { + case V4L2_FIELD_SEQ_TB: + fmt_src.format.field = V4L2_FIELD_INTERLACED_TB; + break; + case V4L2_FIELD_SEQ_BT: + fmt_src.format.field = V4L2_FIELD_INTERLACED_BT; + break; + default: + break; + } + } + imx_media_mbus_fmt_to_pix_fmt(&f->fmt.pix, &fmt_src.format, cc); return 0; diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 1c468ec..8be1033 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -395,16 +395,18 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) struct imx_media_video_dev *vdev = priv->vdev; const struct imx_media_pixfmt *incc; struct v4l2_mbus_framefmt *infmt; + struct v4l2_mbus_framefmt *outfmt; + bool passthrough, interweave; struct ipu_image image; u32 passthrough_bits; u32 passthrough_cycles; dma_addr_t phys[2]; - bool passthrough; u32 burst_size; int ret; infmt = &priv->format_mbus[CSI_SINK_PAD]; incc = priv->cc[CSI_SINK_PAD]; + outfmt = &priv->format_mbus[CSI_SRC_PAD_IDMAC]; ipu_cpmem_zero(priv->idmac_ch); @@ -421,6 +423,14 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) passthrough = requires_passthrough(&priv->upstream_ep, infmt, incc); passthrough_cycles = 1; + /* + * If the field type at capture interface is interlaced, and + * the output IDMAC pad is sequential, enable interweave at + * the IDMAC output channel. + */ + interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: @@ -506,8 +516,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ipu_smfc_set_burstsize(priv->smfc, burst_size); - if (image.pix.field == V4L2_FIELD_NONE && - V4L2_FIELD_HAS_BOTH(infmt->field)) + if (interweave) ipu_cpmem_interlaced_scan(priv->idmac_ch, image.pix.bytesperline, image.pix.pixelformat); @@ -1297,6 +1306,38 @@ static int csi_get_fmt(struct v4l2_subdev *sd, return ret; } +static void csi_try_field(struct csi_priv *priv, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat) +{ + struct v4l2_mbus_framefmt *infmt = + __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which); + + /* no restrictions on sink pad field type */ + if (sdformat->pad == CSI_SINK_PAD) + return; + + switch (infmt->field) { + case V4L2_FIELD_SEQ_TB: + case V4L2_FIELD_SEQ_BT: + case V4L2_FIELD_ALTERNATE: + /* + * If the sink is sequential or alternating fields, + * allow only SEQ_TB at the source. + * + * This driver does not support alternate field mode, and + * the CSI captures a whole frame, so the CSI never presents + * alternate mode at its source pads. + */ + sdformat->format.field = V4L2_FIELD_SEQ_TB; + break; + default: + /* Passthrough for all other input field types */ + sdformat->format.field = infmt->field; + break; + } +} + static void csi_try_fmt(struct csi_priv *priv, struct v4l2_fwnode_endpoint *upstream_ep, struct v4l2_subdev_pad_config *cfg, @@ -1336,25 +1377,14 @@ static void csi_try_fmt(struct csi_priv *priv, } } - if (sdformat->pad == CSI_SRC_PAD_DIRECT || - sdformat->format.field != V4L2_FIELD_NONE) - sdformat->format.field = infmt->field; - - /* - * translate V4L2_FIELD_ALTERNATE to SEQ_TB or SEQ_BT - * depending on input height (assume NTSC top-bottom - * order if 480 lines, otherwise PAL bottom-top order). - */ - if (sdformat->format.field == V4L2_FIELD_ALTERNATE) { - sdformat->format.field = (infmt->height == 480) ? - V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT; - } + csi_try_field(priv, cfg, sdformat); /* propagate colorimetry from sink */ sdformat->format.colorspace = infmt->colorspace; sdformat->format.xfer_func = infmt->xfer_func; sdformat->format.quantization = infmt->quantization; sdformat->format.ycbcr_enc = infmt->ycbcr_enc; + break; case CSI_SINK_PAD: v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W, @@ -1382,6 +1412,8 @@ static void csi_try_fmt(struct csi_priv *priv, sdformat->format.code = (*cc)->codes[0]; } + csi_try_field(priv, cfg, sdformat); + imx_media_fill_default_mbus_fields( &sdformat->format, infmt, priv->active_output_pad == CSI_SRC_PAD_DIRECT); From patchwork Wed Aug 1 19:12:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97CEF13BF for ; Wed, 1 Aug 2018 19:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 924FD2AC4B for ; Wed, 1 Aug 2018 19:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 866012B8A5; Wed, 1 Aug 2018 19:13:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 27BF32AC4B for ; Wed, 1 Aug 2018 19:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387829AbeHAVAE (ORCPT ); Wed, 1 Aug 2018 17:00:04 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44133 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeHAVAD (ORCPT ); Wed, 1 Aug 2018 17:00:03 -0400 Received: by mail-pf1-f196.google.com with SMTP id k21-v6so8334383pff.11; Wed, 01 Aug 2018 12:12:50 -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=DTd4/8cDqyBu2yWckg8cZ6M10oFFB1hFkTUQhaOWB88=; b=Er8yVqsN7ZZww3P5sG+8tEgjiLrb4bao4p6hs08TaXOWR4TSB84xqmFcQQKaZcpAxK WfaTbkW/niyXZS3dVUKn+pME1Xp930gdtDBPHfVUgcflzqBO0n/3ZGeogE6PcmfB2K5g qp0ahF1lrzRY+PaZ3xckVYXUy9L9Ucd3UgVA3C0Ly4r4ZVo7+4zsu78I8Pu9irhgECa0 Epcasn41CATxY3q3A0zpdaM8gdSfKNMF2yDgBwR1Px9rzFtvBShPi3HT6425cXOHg8TL /cJGC5hXl3HRLEljIixY/5sWG+QpFkgzj5omvkWo48GUTXt+z6k8ozmn3BWwe/F5fUk3 UfdQ== 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=DTd4/8cDqyBu2yWckg8cZ6M10oFFB1hFkTUQhaOWB88=; b=O4663yPJLICxmy6Z5JYwb1nYWVSq8F9KFJgybZ5DZSVVhTq63JRZklv2bLDlvmUEfo 2qR+5VCrjdG+wRW6AiXhk4DP1nJP/YJ8w8+crEPysAkuGXKBTY/ZHsVVv2S8N09CttlR /kIpQ8BaC25SfFw+UYKaZumJyzSXo7OAej8U+XODbKpAm7jM/nbqI4CpjTvU0lLPisYm hkntUHpfo08GBFztzR6Jxq+/P5fR4OkUvTV0HGcf4c/+4fqXddAmLyYrtKck9NQw6oct vNAGZ8OMoCgWM8KjCKXtsW2Ii5ububtleDz/AQI40CG2dvRBkdsNpXyZUZ+FEkwh7z5p oHBA== X-Gm-Message-State: AOUpUlHAwFKOuCk2vWu1JUkm7dzC4PMIanuVDCX9xg3PQrJ6tSwbPIMB AphXdreTS/kXoDrJ0o4Wq50nrFEl X-Google-Smtp-Source: AAOMgpdvpAvlH+9EFwzEWHKPM/5qLL+rJcyEX3el1MJcSBhZCiDiWatjQBWeIu/1Br2SYl7rS6qosA== X-Received: by 2002:a63:161a:: with SMTP id w26-v6mr26353701pgl.257.1533150769542; Wed, 01 Aug 2018 12:12:49 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:48 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 08/14] media: imx-csi: Double crop height for alternate fields at sink Date: Wed, 1 Aug 2018 12:12:21 -0700 Message-Id: <1533150747-30677-9-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 If the incoming sink field type is alternate, the reset crop height and crop height bounds must be set to twice the incoming height, because in alternate field mode, upstream will report only the lines for a single field, and the CSI captures the whole frame. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 8be1033..3a09a9b 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1135,6 +1135,8 @@ static void csi_try_crop(struct csi_priv *priv, struct v4l2_mbus_framefmt *infmt, struct v4l2_fwnode_endpoint *upstream_ep) { + u32 in_height; + crop->width = min_t(__u32, infmt->width, crop->width); if (crop->left + crop->width > infmt->width) crop->left = infmt->width - crop->width; @@ -1142,6 +1144,10 @@ static void csi_try_crop(struct csi_priv *priv, crop->left &= ~0x3; crop->width &= ~0x7; + in_height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + in_height *= 2; + /* * FIXME: not sure why yet, but on interlaced bt.656, * changing the vertical cropping causes loss of vertical @@ -1151,12 +1157,12 @@ static void csi_try_crop(struct csi_priv *priv, if (upstream_ep->bus_type == V4L2_MBUS_BT656 && (V4L2_FIELD_HAS_BOTH(infmt->field) || infmt->field == V4L2_FIELD_ALTERNATE)) { - crop->height = infmt->height; - crop->top = (infmt->height == 480) ? 2 : 0; + crop->height = in_height; + crop->top = (in_height == 480) ? 2 : 0; } else { - crop->height = min_t(__u32, infmt->height, crop->height); - if (crop->top + crop->height > infmt->height) - crop->top = infmt->height - crop->height; + crop->height = min_t(__u32, in_height, crop->height); + if (crop->top + crop->height > in_height) + crop->top = in_height - crop->height; } } @@ -1396,6 +1402,8 @@ static void csi_try_fmt(struct csi_priv *priv, crop->top = 0; crop->width = sdformat->format.width; crop->height = sdformat->format.height; + if (sdformat->format.field == V4L2_FIELD_ALTERNATE) + crop->height *= 2; csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); compose->left = 0; compose->top = 0; @@ -1523,6 +1531,8 @@ static int csi_get_selection(struct v4l2_subdev *sd, sel->r.top = 0; sel->r.width = infmt->width; sel->r.height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + sel->r.height *= 2; break; case V4L2_SEL_TGT_CROP: sel->r = *crop; From patchwork Wed Aug 1 19:12:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0903915E9 for ; Wed, 1 Aug 2018 19:13:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02AE82AC4B for ; Wed, 1 Aug 2018 19:13:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF232B8A5; Wed, 1 Aug 2018 19:13:34 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 8CCEB2AC4B for ; Wed, 1 Aug 2018 19:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387997AbeHAVAH (ORCPT ); Wed, 1 Aug 2018 17:00:07 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33853 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeHAVAG (ORCPT ); Wed, 1 Aug 2018 17:00:06 -0400 Received: by mail-pg1-f195.google.com with SMTP id y5-v6so11286816pgv.1; Wed, 01 Aug 2018 12:12:52 -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 :mime-version:content-transfer-encoding; bh=sSPF0uv+LV63rAW2xHOcPWmuyOhu/C4pUSRq2lopMiU=; b=NL/x5Ri8Ljv2qYm06H5CR/L//i2n5iMsJUA5TyYuvnVerw7fsrcoYPrijfCcUmCZsT bCGuvM5SIzL87+cbJr6w600k6OxBGzsZ/+tq4mAmAzv5KyBiINTYWluSMDsun8YZGQhD EzxtB1zcaYWS4UZcvPdHn+6btue5Q8fKYt5nz9kO8s49qssuZ5HpRWINy+LfAW3VmA8D eDhuanOAHHiPvpwwIf3ha6r/jil45VFzy4dSQetnpR51GyLjBJKZoaIta115NcCbiYT5 7zluc4QB0x7TyPc4QnAfEtuLk8SXMtq7wnT3RomRWDRkuAlkEH9ub4rgRCNMlIwl6yW5 WE7g== 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:mime-version:content-transfer-encoding; bh=sSPF0uv+LV63rAW2xHOcPWmuyOhu/C4pUSRq2lopMiU=; b=R1ON1Fj7uUImxPvCLa95gcjEMjrv87feE5YrCtm3UY6CX5VgTafLUIk9XoJfMmk2Ut jL+ItYAZv1eyw4N+59kLmcNtlCStCLWoAyBPNzxTlHdhO61HrvfR68QlI3E4TUhm2J7e CyKgwAizhmOW6M33BtxHQRP16XgCK9x9Oag8QYXl8FBmxi1XgYGS5k7Cqo4JOwlE/ip7 /4Kjm3LFkSIjAfe4Po3Z5GZo1gFvFKhE2vkYXaxdAMOR1MLiJfRFZBtPnGunCeEM9taY ZFC67q2U8QXAfvQtH2GXn2Zb1YzEqIvsdQ47p6Bl5BhjGkz1WjO8Yqs4NsBmV3/bDPP+ oHow== X-Gm-Message-State: AOUpUlFWlOwVMFURZyNNuW8DZ8yE06ej8TDnos6fBwYXsibl103yeRxG KGQJYz6wFrPskWcBaU37HosIe82k X-Google-Smtp-Source: AAOMgpc6vS5vhgmqHvq1WpkuM0ZiSiuOtIE5Q5XpehKYosTRw+G9nlQRBdxss5aSCRntQJw8QSQZmg== X-Received: by 2002:a65:5784:: with SMTP id b4-v6mr26333967pgr.315.1533150771303; Wed, 01 Aug 2018 12:12:51 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:50 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 09/14] media: imx: interweave and odd-chroma-row skip are incompatible Date: Wed, 1 Aug 2018 12:12:22 -0700 Message-Id: <1533150747-30677-10-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> MIME-Version: 1.0 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 If IDMAC interweaving is enabled in a write channel, the channel must write the odd chroma rows for 4:2:0 formats. Skipping writing the odd chroma rows produces corrupted captured 4:2:0 images when interweave is enabled. Reported-by: Krzysztof HaƂasa Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +++++++-- drivers/staging/media/imx/imx-media-csi.c | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 1a03d4c..cf76b04 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -391,12 +391,17 @@ static int prp_setup_channel(struct prp_priv *priv, image.phys0 = addr0; image.phys1 = addr1; - if (channel == priv->out_ch || channel == priv->rot_out_ch) { + /* + * Skip writing U and V components to odd rows in the output + * channels for planar 4:2:0 (but not when enabling IDMAC + * interweaving, they are incompatible). + */ + if (!interweave && (channel == priv->out_ch || + channel == priv->rot_out_ch)) { switch (image.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_NV12: - /* Skip writing U and V components to odd rows */ ipu_cpmem_skip_odd_chroma_rows(channel); break; } diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 3a09a9b..1155d50d 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -454,8 +454,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ((image.pix.width & 0x1f) ? ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64; passthrough_bits = 16; - /* Skip writing U and V components to odd rows */ - ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch); + /* + * Skip writing U and V components to odd rows (but not + * when enabling IDMAC interweaving, they are incompatible). + */ + if (!interweave) + ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch); break; case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_UYVY: From patchwork Wed Aug 1 19:12:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94F3313BF for ; Wed, 1 Aug 2018 19:13:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E56C2AC4B for ; Wed, 1 Aug 2018 19:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8226F2B8A5; Wed, 1 Aug 2018 19:13:32 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 26A702AC4B for ; Wed, 1 Aug 2018 19:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387714AbeHAVAi (ORCPT ); Wed, 1 Aug 2018 17:00:38 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44857 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387947AbeHAVAH (ORCPT ); Wed, 1 Aug 2018 17:00:07 -0400 Received: by mail-pg1-f196.google.com with SMTP id r1-v6so11277288pgp.11; Wed, 01 Aug 2018 12:12:53 -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=G+4fTSjJ9qr6z0CdGSqqT0aewFdBL1/h41q/NxuvRPo=; b=QOG0t0tqVTRE+QhHU9EIW52E6G0qyYatjYd/Rc5y8LA2JJ5mTozV75auPhDjmFJOQK /Zcs5tS2kaOkOzmic0IKMZS87wvuDBVEAEyoaIwMREduk5oOqN8NFgDuioOTHC/12P/1 fXxHj5WugX2kVGqoqL79BUN0spgVcJBh1x8Q+x6cJRkJuL8YrEcVx8BHVZV193EBe45w uSUPH4oZdm8NrITbedqiptqSenHnWZbilhn857LgCZIgwGP4Pa9M/AjAADIyFJJwnX4w QDn/6WKaF2/fGIs/PfaC1jbxKRa1k1DYnuupyB+C9tjTWNofN0I9fwmdEe2JzeKC+6f0 6A1A== 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=G+4fTSjJ9qr6z0CdGSqqT0aewFdBL1/h41q/NxuvRPo=; b=hEBfwCbBfdFMgxkuHYEYSas3hWx3nvX1a8jSIag7oyAS/cnwmPcJv9uzR4WY2UGrVL 1xfh9XNn3zl7L0mmYROYblxguI2Ts84ROFuF8AbXM4kfDttYAO4jsUE8BfFLBUiIk1Um 7wBc3PXG3m/RJRL41tyQ7AVJsUuNzel+8tNYYxbA+cTRHfnQitmauhLR8fbn8wxQDEqK GpsUVXMBz/8rd7QRDSLrp8t+cAfW1MQ0HtMqVjmPKxfuO3Tc00sGmXIpxMsD3w3J+6DF UVPyPk3TTYkzEgzxBbmxEuSLPpqw8gYWCQzTngyHOXryJqW4EWJW837HJp3wCRj/Js7j Iwgg== X-Gm-Message-State: AOUpUlHjgQMfXuz0Ggh57Yk3HpfA/ORbb+p9K7Wr8c+xTz327mVtwrMC +FmoyjXLuVpWZrR4lRwEsnXy1X8b X-Google-Smtp-Source: AAOMgpfr2m7pXsD7iAypOe/5whKC6tU+PpXr+UJtACEL02rgpcJi9aldQpTpN3RqeQORD85ubK5YMw== X-Received: by 2002:a63:aa44:: with SMTP id x4-v6mr26090828pgo.120.1533150773055; Wed, 01 Aug 2018 12:12:53 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:52 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 10/14] media: imx-csi: Allow skipping odd chroma rows for YVU420 Date: Wed, 1 Aug 2018 12:12:23 -0700 Message-Id: <1533150747-30677-11-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 Skip writing U/V components to odd rows for YVU420 in addition to YUV420 and NV12. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-media-csi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 1155d50d..139c694 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -449,6 +449,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) passthrough_bits = 16; break; case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_NV12: burst_size = (image.pix.width & 0x3f) ? ((image.pix.width & 0x1f) ? From patchwork Wed Aug 1 19:12:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EC9813BF for ; Wed, 1 Aug 2018 19:13:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 376BA2AC4B for ; Wed, 1 Aug 2018 19:13:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B4A72B8A5; Wed, 1 Aug 2018 19:13:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 C513A2AC4B for ; Wed, 1 Aug 2018 19:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388304AbeHAVAJ (ORCPT ); Wed, 1 Aug 2018 17:00:09 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37750 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeHAVAJ (ORCPT ); Wed, 1 Aug 2018 17:00:09 -0400 Received: by mail-pg1-f196.google.com with SMTP id n7-v6so11288899pgq.4; Wed, 01 Aug 2018 12:12:55 -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=/YRmqT4C9CxqI1MsWRMLxEa0Dl12XnFTogc0Db1UUOo=; b=lKv7IvQ/7/iEDaC/xcq44vED9EAs9FzQI+lMxh76MNmZB0V8NNR7lVtW6Uhlh7oMwH hjT/7WDjZQ7c6gJCDfIO/qv7ZJlZ2aflDN2ZWS/jZOOWjhtvF7FoAR/wXJlbQa/zMBF4 Os3jlUeFgqP25UjLxE2xJCe+us/Mf3b5u2Y1OiOFikqbH9Wnh9SN0q0TsvxIwT11aKBu LScpBuda+gBuQFrHzh5O0TD+GDPHHJ+JRRe8oZJMHEerJyT48hsyVFDckRkZkQveVCQh XTetWHeehiHHU0zfs0aQhRkCsq/Oh5TlznL+oKRPq+5FarKLy/hGcJ9BWcGbXrwnMIWj avOA== 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=/YRmqT4C9CxqI1MsWRMLxEa0Dl12XnFTogc0Db1UUOo=; b=jiIzc+X+6thSibWRh3nHNH9QMS++T0+d8vrO6uoDLVkE7Lyqtm35BuCYFd6WGFzOJX I1ooGmceGJI+A8iykppNZxsK1R29tMHIMsTe4b8AV5QabFyLwaU89BcBwNhQ3cbmlmPY 7pgv9+jIwIBLwVrtSjHNJ/NVedmLlx6SUTrT0/gL5gYOtfChavQj4uiWwcsAXn+XWF+p z4Odno+QC2g/4yKMCbmr1doc7AE7WrJKBA0JqYm8x7AFXbHxmo+PqRRB+bn3L3ik46gs ybRHvavaGdJq1xUnnDkoRzPpUS65oUqqQG32OVrxpfR8OY13FcgAXobsln2d2hrPHchg jVFQ== X-Gm-Message-State: AOUpUlEZMS4EiR/MHmm4stPSrANvl0QDe8FxJ6xTP+ahE7Ge8MiJUcko e7utTeKJeKMkZ6mOY9JX/lZYfopC X-Google-Smtp-Source: AAOMgpdcWKKNotURBAvfdIt+TLxB6bGC7F9tFyEtkQqVJNtz8U7d/oEOzmCbAiCWjsCaQuIDqx1Wrg== X-Received: by 2002:a63:fb07:: with SMTP id o7-v6mr26239583pgh.333.1533150774795; Wed, 01 Aug 2018 12:12:54 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:53 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 11/14] media: imx: vdic: rely on VDIC for correct field order Date: Wed, 1 Aug 2018 12:12:24 -0700 Message-Id: <1533150747-30677-12-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 prepare_vdi_in_buffers() was setting up the dma pointers as if the VDIC is always programmed to receive the fields in bottom-top order, i.e. as if ipu_vdi_set_field_order() only programs BT order in the VDIC. But that's not true, ipu_vdi_set_field_order() is working correctly. So fix prepare_vdi_in_buffers() to give the VDIC the fields in whatever order they were received by the video source, and rely on the VDIC to sort out which is top and which is bottom. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-vdic.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c index 482250d..4a89071 100644 --- a/drivers/staging/media/imx/imx-media-vdic.c +++ b/drivers/staging/media/imx/imx-media-vdic.c @@ -219,26 +219,18 @@ static void __maybe_unused prepare_vdi_in_buffers(struct vdic_priv *priv, switch (priv->fieldtype) { case V4L2_FIELD_SEQ_TB: - prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0); - curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs; - next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); - break; case V4L2_FIELD_SEQ_BT: prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + fs; curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs; break; + case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: + case V4L2_FIELD_INTERLACED: prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + is; curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is; break; - default: - /* assume V4L2_FIELD_INTERLACED_TB */ - prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0); - curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is; - next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); - break; } ipu_cpmem_set_buffer(priv->vdi_in_ch_p, 0, prev_phys); From patchwork Wed Aug 1 19:12:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B80813BF for ; Wed, 1 Aug 2018 19:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23F0627F93 for ; Wed, 1 Aug 2018 19:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1813528649; Wed, 1 Aug 2018 19:13:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 AF98A27F93 for ; Wed, 1 Aug 2018 19:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388522AbeHAVAM (ORCPT ); Wed, 1 Aug 2018 17:00:12 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40277 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeHAVAK (ORCPT ); Wed, 1 Aug 2018 17:00:10 -0400 Received: by mail-pg1-f195.google.com with SMTP id x5-v6so11280322pgp.7; Wed, 01 Aug 2018 12:12:57 -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=JpaT7TRpuSXZsxMI4cnEQZ2GiNweb/AOqE4Z7IOYzao=; b=bnh3ViqEk96whARsVe9lmdaqtlA5Ndg5PZMa2ULQjRqoWl+7mvZ4UoAJQJ8F2xdsN0 3DdDxQCZ5cMsvWG0XXXX76NcDlYt2Fu9pppV+mEGm7ZQhuJIAmZqMXeg0ecKNlslCZXY aSNkT94xCw649W0uOR2DQqCHdYQBA6GyX/jilKREg2XCnjMFUAQvmFB7Fy9snl+rSYi9 ImzObvA1sbMXw7fbV9lHcMsqskZwHXHtd1y67ERmUjS8NJY7jgnlnoFB0cweL06wrwCa 7bj4KMTgJNFlDzHVs1H7by9XOXakmzCRvXpDpw0XKwPjbMtZ84BaYRadPJrQvmVSHlrO F0oQ== 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=JpaT7TRpuSXZsxMI4cnEQZ2GiNweb/AOqE4Z7IOYzao=; b=DtFTVJfQ5OedxrApoTNbow49JwTQBbls+aHCMht6YtIJRo1fp7aXv3Bez4GahtzXOk qwcLKGYWZeCcCKtlT+Xoy8PS3FJTyUq8tJfH/pd04u3Sd5v66gTeL9smxpJEttryf8Zi qDVSUSW72U/HBak1iE0JM3T+yXXqCr1OhOF01N86QJS2NZIuvSoQnxVW4RdkINJ7NSNB TTdhMT8nIK56YnKQKLGY0Sdm03WnNb6jdm0QpOX4SL22kWDD6mwMSpG0hfFKMCQWDfSk SQ37T2T2oUYmkCxafB77nwO/mKOOFH7rzgl84MGsDA284fT53PRYHeG3ovGjyPGMFRTb Q5Cg== X-Gm-Message-State: AOUpUlEvp57z760hcWrQx/6n7n5ysW4SEQP5jUM4HAPz3gN6fLHRBuT9 vfBo39u728opAzRMvtTVvyFzYtBW X-Google-Smtp-Source: AAOMgpcVmWYGBmny/26co1muyKVIg2JSRM8Kd5wh8H77QJdYA6rha1ge1JHLLjCiASz090X9UlXP7g== X-Received: by 2002:a62:ee06:: with SMTP id e6-v6mr27994269pfi.2.1533150776569; Wed, 01 Aug 2018 12:12:56 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:55 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 12/14] media: imx-csi: Move crop/compose reset after filling default mbus fields Date: Wed, 1 Aug 2018 12:12:25 -0700 Message-Id: <1533150747-30677-13-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 If caller passes un-initialized field type V4L2_FIELD_ANY to CSI sink pad, the reset CSI crop window would not be correct, because the crop window depends on a valid input field type. To fix move the reset of crop and compose windows to after the call to imx_media_fill_default_mbus_fields(). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 139c694..6f24b3b 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1402,19 +1402,6 @@ static void csi_try_fmt(struct csi_priv *priv, W_ALIGN, &sdformat->format.height, MIN_H, MAX_H, H_ALIGN, S_ALIGN); - /* Reset crop and compose rectangles */ - crop->left = 0; - crop->top = 0; - crop->width = sdformat->format.width; - crop->height = sdformat->format.height; - if (sdformat->format.field == V4L2_FIELD_ALTERNATE) - crop->height *= 2; - csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); - compose->left = 0; - compose->top = 0; - compose->width = crop->width; - compose->height = crop->height; - *cc = imx_media_find_mbus_format(sdformat->format.code, CS_SEL_ANY, true); if (!*cc) { @@ -1430,6 +1417,20 @@ static void csi_try_fmt(struct csi_priv *priv, imx_media_fill_default_mbus_fields( &sdformat->format, infmt, priv->active_output_pad == CSI_SRC_PAD_DIRECT); + + /* Reset crop and compose rectangles */ + crop->left = 0; + crop->top = 0; + crop->width = sdformat->format.width; + crop->height = sdformat->format.height; + if (sdformat->format.field == V4L2_FIELD_ALTERNATE) + crop->height *= 2; + csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); + compose->left = 0; + compose->top = 0; + compose->width = crop->width; + compose->height = crop->height; + break; } } From patchwork Wed Aug 1 19:12:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 754BE15E9 for ; Wed, 1 Aug 2018 19:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EC5427CEE for ; Wed, 1 Aug 2018 19:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63462285C7; Wed, 1 Aug 2018 19:13:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 BC60D284A7 for ; Wed, 1 Aug 2018 19:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732419AbeHAVAO (ORCPT ); Wed, 1 Aug 2018 17:00:14 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33051 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbeHAVAN (ORCPT ); Wed, 1 Aug 2018 17:00:13 -0400 Received: by mail-pg1-f193.google.com with SMTP id r5-v6so11288266pgv.0; Wed, 01 Aug 2018 12:12:59 -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=Vul4BX0gqUQj2X+LXwtup1oCQZDlN1EYdrwF6xIY0wM=; b=vNzlBddqB2IFoBskK28rdOSB+KkOEhb2VpQFVM7Fbmgxihg7NEgJlLfAnC5gZJdu8Q 32DWa32cmQ5qHWXU/B3ayT4+7/PpBBE6L02iJg3AeUISKz4OkT1BeQKDIi6aefB+XnRu PupAhkJpDvRBznW9BbZ7BY61ToFB49PVrZEXEdhthHPbbCRJh3kX3XPOMXXpLObhBySq FJcJ+g8ulQA3MJgqcADJZmzDUo/KMorNlGCUNwUP12EL1TFBXeEscYnftLzc2PKM5n+I ROHw5g/wVJ6O8RCZwoRSHfkcxz1Hf3SDQIh/xeOJVbh41G6DcRBK6i/EsR4+8cNkkR6C VZgQ== 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=Vul4BX0gqUQj2X+LXwtup1oCQZDlN1EYdrwF6xIY0wM=; b=SY173VmM85iLcHcx5zAjidG51cjCbbsCcLREBNB0RByr5XqrR9mTva8Ubt3wh2Dqpe wCyQWEPoBzGTIADowVmwWbEMd0AHDhJRs8seQQGNZW+jqFEhsIb5UUskGJYXfVyiEuik Ay4bbBsXFeKH9QO79ldLAyKqLbKK2kkLcDd+ojx9IW/rPXq2zBwpicQ1cwUwlHMDjiOy nbdR3BBI/HSZzxNOIk/Kk+33EaHWtGa6DOaDBQi72PsjsYbFxXJCL6DDcMbOYLH/obdE eoDOqbeMiquJJMpllkA1RAiJiGhZtOEPxg0y9vikWQWW8kUL66FJCWBL6OhbkOHrueAt jhlw== X-Gm-Message-State: AOUpUlGZcpS6XorkSekgfur/w6usVv02FeYY8DSJXuhjhbIc9umZ7jQy 2GxIeen7ykPY2iMsmxSPZYetKLy1 X-Google-Smtp-Source: AAOMgpfv6arENTk73DuY+TpIarGmW1HmfmXuak+5FHjmRFrbOxQKnwHh/jcu1SVSqom6+22yEaH33g== X-Received: by 2002:a62:9d14:: with SMTP id i20-v6mr28164809pfd.3.1533150778361; Wed, 01 Aug 2018 12:12:58 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:57 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 13/14] media: imx: Allow interweave with top/bottom lines swapped Date: Wed, 1 Aug 2018 12:12:26 -0700 Message-Id: <1533150747-30677-14-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 Allow sequential->interlaced interweaving but with top/bottom lines swapped to the output buffer. This can be accomplished by adding one line length to IDMAC output channel address, with a negative line length for the interlace offset. This is to allow the seq-bt -> interlaced-bt transformation, where bottom lines are still dominant (older in time) but with top lines first in the interweaved output buffer. With this support, the CSI can now allow seq-bt at its source pads, e.g. the following transformations are allowed in CSI from sink to source: seq-tb -> seq-bt seq-bt -> seq-bt alternate -> seq-bt Suggested-by: Philipp Zabel Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-ic-prpencvf.c | 17 ++++++++++- drivers/staging/media/imx/imx-media-csi.c | 46 +++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index cf76b04..1499b0c 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -106,6 +106,8 @@ struct prp_priv { u32 frame_sequence; /* frame sequence counter */ bool last_eof; /* waiting for last EOF at stream off */ bool nfb4eof; /* NFB4EOF encountered during streaming */ + u32 interweave_offset; /* interweave line offset to swap + top/bottom lines */ struct completion last_eof_comp; }; @@ -235,6 +237,9 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct ipuv3_channel *ch) if (ipu_idmac_buffer_is_ready(ch, priv->ipu_buf_num)) ipu_idmac_clear_buffer(ch, priv->ipu_buf_num); + if (ch == priv->out_ch) + phys += priv->interweave_offset; + ipu_cpmem_set_buffer(ch, priv->ipu_buf_num, phys); } @@ -388,6 +393,13 @@ static int prp_setup_channel(struct prp_priv *priv, (image.pix.width * outcc->bpp) >> 3; } + priv->interweave_offset = 0; + + if (interweave && image.pix.field == V4L2_FIELD_INTERLACED_BT) { + image.rect.top = 1; + priv->interweave_offset = image.pix.bytesperline; + } + image.phys0 = addr0; image.phys1 = addr1; @@ -425,7 +437,10 @@ static int prp_setup_channel(struct prp_priv *priv, ipu_cpmem_set_rotation(channel, rot_mode); if (interweave) - ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, + ipu_cpmem_interlaced_scan(channel, + priv->interweave_offset ? + -image.pix.bytesperline : + image.pix.bytesperline, image.pix.pixelformat); ret = ipu_ic_task_idma_init(priv->ic, channel, diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 6f24b3b..a5f88ae 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -114,6 +114,8 @@ struct csi_priv { u32 frame_sequence; /* frame sequence counter */ bool last_eof; /* waiting for last EOF at stream off */ bool nfb4eof; /* NFB4EOF encountered during streaming */ + u32 interweave_offset; /* interweave line offset to swap + top/bottom lines */ struct completion last_eof_comp; }; @@ -283,7 +285,8 @@ static void csi_vb2_buf_done(struct csi_priv *priv) if (ipu_idmac_buffer_is_ready(priv->idmac_ch, priv->ipu_buf_num)) ipu_idmac_clear_buffer(priv->idmac_ch, priv->ipu_buf_num); - ipu_cpmem_set_buffer(priv->idmac_ch, priv->ipu_buf_num, phys); + ipu_cpmem_set_buffer(priv->idmac_ch, priv->ipu_buf_num, + phys + priv->interweave_offset); } static irqreturn_t csi_idmac_eof_interrupt(int irq, void *dev_id) @@ -393,10 +396,10 @@ static void csi_idmac_unsetup_vb2_buf(struct csi_priv *priv, static int csi_idmac_setup_channel(struct csi_priv *priv) { struct imx_media_video_dev *vdev = priv->vdev; + bool passthrough, interweave, interweave_swap; const struct imx_media_pixfmt *incc; struct v4l2_mbus_framefmt *infmt; struct v4l2_mbus_framefmt *outfmt; - bool passthrough, interweave; struct ipu_image image; u32 passthrough_bits; u32 passthrough_cycles; @@ -430,6 +433,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) */ interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + interweave_swap = interweave && + image.pix.field == V4L2_FIELD_INTERLACED_BT; switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: @@ -483,15 +488,25 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) } if (passthrough) { + priv->interweave_offset = interweave_swap ? + image.pix.bytesperline : 0; ipu_cpmem_set_resolution(priv->idmac_ch, image.rect.width * passthrough_cycles, 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_buffer(priv->idmac_ch, 0, + image.phys0 + priv->interweave_offset); + ipu_cpmem_set_buffer(priv->idmac_ch, 1, + image.phys1 + priv->interweave_offset); ipu_cpmem_set_format_passthrough(priv->idmac_ch, passthrough_bits); } else { + priv->interweave_offset = 0; + if (interweave_swap) { + image.rect.top = 1; + priv->interweave_offset = image.pix.bytesperline; + } + ret = ipu_cpmem_set_image(priv->idmac_ch, &image); if (ret) goto unsetup_vb2; @@ -523,6 +538,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) if (interweave) ipu_cpmem_interlaced_scan(priv->idmac_ch, + priv->interweave_offset ? + -image.pix.bytesperline : image.pix.bytesperline, image.pix.pixelformat); @@ -1331,16 +1348,27 @@ static void csi_try_field(struct csi_priv *priv, switch (infmt->field) { case V4L2_FIELD_SEQ_TB: case V4L2_FIELD_SEQ_BT: + /* + * If the user requests sequential at the source pad, + * allow it (along with possibly inverting field order). + * Otherwise passthrough the field type. + */ + if (!V4L2_FIELD_IS_SEQUENTIAL(sdformat->format.field)) + sdformat->format.field = infmt->field; + break; case V4L2_FIELD_ALTERNATE: /* - * If the sink is sequential or alternating fields, - * allow only SEQ_TB at the source. - * * This driver does not support alternate field mode, and * the CSI captures a whole frame, so the CSI never presents - * alternate mode at its source pads. + * alternate mode at its source pads. If user has not + * already requested sequential, translate ALTERNATE at + * sink pad to SEQ_TB or SEQ_BT at the source pad depending + * on input height (assume NTSC BT order if 480 total active + * frame lines, otherwise PAL TB order). */ - sdformat->format.field = V4L2_FIELD_SEQ_TB; + if (!V4L2_FIELD_IS_SEQUENTIAL(sdformat->format.field)) + sdformat->format.field = (infmt->height == 480 / 2) ? + V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB; break; default: /* Passthrough for all other input field types */ From patchwork Wed Aug 1 19:12:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10552847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7751415E9 for ; Wed, 1 Aug 2018 19:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EE662621E for ; Wed, 1 Aug 2018 19:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60866283F1; Wed, 1 Aug 2018 19:13:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 910E62621E for ; Wed, 1 Aug 2018 19:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388526AbeHAVAQ (ORCPT ); Wed, 1 Aug 2018 17:00:16 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42158 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbeHAVAP (ORCPT ); Wed, 1 Aug 2018 17:00:15 -0400 Received: by mail-pf1-f193.google.com with SMTP id l9-v6so8339008pff.9; Wed, 01 Aug 2018 12:13:00 -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=RsI8GdaIVh0ebptJPIHBq6I6bN0KBzCe/VCfGdsbyVk=; b=HeV4fL7qrg/lhbX5k3neh6NdLgVoB+RYjFuZPGY+YXJzwz9RLWquJJyxHEr+w01tbn gTt2QAbimeW8EXeBXNpKnCwygLlgKAZjFlfcPOzicmbGnydG/X9gfCD5JbZX7w/Ms6ZP AQJWYQKloMZrw3e8NzuRw6DDR7cgk5S1Y6UnG5OslZeNXuQhgRvTXA7lznWK2LCnUCBX LaNMdU03BLQ0tofzBuTJbTaEgQ1JII3RPabDFXf4+koXb7Vy14pjeZKjHLQDfc30OYpf k78hAao74WImU+eq5FlOniv5/pvDUzmUNX45jqnFyOPx13zvGYmk96BhzJBKb7JCQOJ0 HClQ== 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=RsI8GdaIVh0ebptJPIHBq6I6bN0KBzCe/VCfGdsbyVk=; b=QgGJQh4LkgbvmnE4QLy70UD36q1ZQ0fxvI00ErGoUTRPm6c/Q5zj5+9OS42HzgM06q B96ZiBInEreVv4q/gJ6RVZNIy7WkwiYb64y0EB+zeeVHK2QP0V5Yb4LOHJ9l4UDCMWLD b3DGXOblkHr0zA7O+LQRDesCxGlN/KxJg92qWdhgDtQfNYAT1QGeC8F2t6trOiPxEcbU tH4jRb9/ZcwbfLdID47OfwZYeFDc3rgbfmHc9MJwaV9TxtctPiuEPawhHEc2wK4pe/mC CgEX0U2AlSjS8E+A+EsFetgz/tIMF/sGiV2AVWw7YdsypvUshXATcWPQ/axGEwaAY7Ad FJHg== X-Gm-Message-State: AOUpUlHixAjsAP6eI1na11i8x1ouFMKom5aU+Q84mQGwQ+wwtsT40QIg ltI9dxdyCTr4/rqTnIV4XrqQYV1g X-Google-Smtp-Source: AAOMgpeNLVtsclx2rIQSVyMKcTumsjhBu7UjBvwlgYGZ5I8aJC+VOJoDqG7wh3Vf6aH//1E9TFyl8Q== X-Received: by 2002:a62:1c13:: with SMTP id c19-v6mr8236596pfc.148.1533150780004; Wed, 01 Aug 2018 12:13:00 -0700 (PDT) Received: from mappy.world.mentorg.com (c-24-5-209-231.hsd1.ca.comcast.net. [24.5.209.231]) by smtp.googlemail.com with ESMTPSA id u42-v6sm31171336pgn.1.2018.08.01.12.12.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 12:12:59 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 14/14] media: imx.rst: Update doc to reflect fixes to interlaced capture Date: Wed, 1 Aug 2018 12:12:27 -0700 Message-Id: <1533150747-30677-15-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> References: <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com> 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 Also add an example pipeline for unconverted capture with interweave on SabreAuto. Signed-off-by: Steve Longerbeam --- Changes since v2: - expand on idmac interweave behavior in CSI subdev. - switch second SabreAuto pipeline example to PAL to give both NTSC and PAL examples. - Cleanup some language in various places. --- Documentation/media/v4l-drivers/imx.rst | 93 +++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 33 deletions(-) diff --git a/Documentation/media/v4l-drivers/imx.rst b/Documentation/media/v4l-drivers/imx.rst index 65d3d15..1f6279d 100644 --- a/Documentation/media/v4l-drivers/imx.rst +++ b/Documentation/media/v4l-drivers/imx.rst @@ -22,8 +22,8 @@ memory. Various dedicated DMA channels exist for both video capture and display paths. During transfer, the IDMAC is also capable of vertical image flip, 8x8 block transfer (see IRT description), pixel component re-ordering (for example UYVY to YUYV) within the same colorspace, and -even packed <--> planar conversion. It can also perform a simple -de-interlacing by interleaving even and odd lines during transfer +packed <--> planar conversion. The IDMAC can also perform a simple +de-interlacing by interweaving even and odd lines during transfer (without motion compensation which requires the VDIC). The CSI is the backend capture unit that interfaces directly with @@ -173,15 +173,19 @@ via the SMFC and an IDMAC channel, bypassing IC pre-processing. This source pad is routed to a capture device node, with a node name of the format "ipuX_csiY capture". -Note that since the IDMAC source pad makes use of an IDMAC channel, it -can do pixel reordering within the same colorspace. For example, the +Note that since the IDMAC source pad makes use of an IDMAC channel, the +CSI can do pixel reordering within the same colorspace. For example, the sink pad can take UYVY2X8, but the IDMAC source pad can output YUYV2X8. If the sink pad is receiving YUV, the output at the capture device can also be converted to a planar YUV format such as YUV420. -It will also perform simple de-interlace without motion compensation, -which is activated if the sink pad's field type is an interlaced type, -and the IDMAC source pad field type is set to none. +The CSI will also perform simple interweave without motion compensation, +which is activated if the source pad's field type is sequential top-bottom +or bottom-top or alternate, and the capture interface field type is set +to interlaced (t-b, b-t, or unqualified interlaced). The capture interface +will enforce the same field order if the source pad field type is seq-bt +or seq-tb. However if the source pad's field type is alternate, any +interlaced type at the capture interface will be accepted. This subdev can generate the following event when enabling the second IDMAC source pad: @@ -323,14 +327,14 @@ ipuX_vdic The VDIC carries out motion compensated de-interlacing, with three motion compensation modes: low, medium, and high motion. The mode is -specified with the menu control V4L2_CID_DEINTERLACING_MODE. It has -two sink pads and a single source pad. +specified with the menu control V4L2_CID_DEINTERLACING_MODE. The VDIC +has two sink pads and a single source pad. The direct sink pad receives from an ipuX_csiY direct pad. With this link the VDIC can only operate in high motion mode. When the IDMAC sink pad is activated, it receives from an output -or mem2mem device node. With this pipeline, it can also operate +or mem2mem device node. With this pipeline, the VDIC can also operate in low and medium modes, because these modes require receiving frames from memory buffers. Note that an output or mem2mem device is not implemented yet, so this sink pad currently has no links. @@ -343,8 +347,8 @@ ipuX_ic_prp This is the IC pre-processing entity. It acts as a router, routing data from its sink pad to one or both of its source pads. -It has a single sink pad. The sink pad can receive from the ipuX_csiY -direct pad, or from ipuX_vdic. +This entity has a single sink pad. The sink pad can receive from the +ipuX_csiY direct pad, or from ipuX_vdic. This entity has two source pads. One source pad routes to the pre-process encode task entity (ipuX_ic_prpenc), the other to the @@ -367,8 +371,8 @@ color-space conversion, resizing (downscaling and upscaling), horizontal and vertical flip, and 90/270 degree rotation. Flip and rotation are provided via standard V4L2 controls. -Like the ipuX_csiY IDMAC source, it can also perform simple de-interlace -without motion compensation, and pixel reordering. +Like the ipuX_csiY IDMAC source, this entity can also perform simple +de-interlace without motion compensation, and pixel reordering. ipuX_ic_prpvf ------------- @@ -378,18 +382,18 @@ pad from ipuX_ic_prp, and a single source pad. The source pad is routed to a capture device node, with a node name of the format "ipuX_ic_prpvf capture". -It is identical in operation to ipuX_ic_prpenc, with the same resizing -and CSC operations and flip/rotation controls. It will receive and -process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is +This entity is identical in operation to ipuX_ic_prpenc, with the same +resizing and CSC operations and flip/rotation controls. It will receive +and process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is receiving from ipuX_vdic. -Like the ipuX_csiY IDMAC source, it can perform simple de-interlace -without motion compensation. However, note that if the ipuX_vdic is -included in the pipeline (ipuX_ic_prp is receiving from ipuX_vdic), -it's not possible to use simple de-interlace in ipuX_ic_prpvf, since -the ipuX_vdic has already carried out de-interlacing (with motion -compensation) and therefore the field type output from ipuX_ic_prp can -only be none. +Like the ipuX_csiY IDMAC source, this entity can perform simple +interweaving without motion compensation. However, note that if the +ipuX_vdic is included in the pipeline (ipuX_ic_prp is receiving from +ipuX_vdic), it's not possible to use interweave in ipuX_ic_prpvf, +since the ipuX_vdic has already carried out de-interlacing (with +motion compensation) and therefore the field type output from +ipuX_vdic can only be none (progressive). Capture Pipelines ----------------- @@ -514,10 +518,33 @@ On the SabreAuto, an on-board ADV7180 SD decoder is connected to the parallel bus input on the internal video mux to IPU1 CSI0. The following example configures a pipeline to capture from the ADV7180 -video decoder, assuming NTSC 720x480 input signals, with Motion -Compensated de-interlacing. Pad field types assume the adv7180 outputs -"interlaced". $outputfmt can be any format supported by the ipu1_ic_prpvf -entity at its output pad: +video decoder, assuming NTSC 720x480 input signals, using simple +interweave (unconverted and without motion compensation). The adv7180 +must output sequential or alternating fields (field type 'seq-bt' for +NTSC, or 'alternate'): + +.. code-block:: none + + # Setup links + media-ctl -l "'adv7180 3-0021':0 -> 'ipu1_csi0_mux':1[1]" + media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]" + media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]" + # Configure pads + media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x480 field:seq-bt]" + media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480]" + media-ctl -V "'ipu1_csi0':2 [fmt:AYUV32/720x480]" + # Configure "ipu1_csi0 capture" interface (assumed at /dev/video4) + v4l2-ctl -d4 --set-fmt-video=field=interlaced_bt + +Streaming can then begin on /dev/video4. The v4l2-ctl tool can also be +used to select any supported YUV pixelformat on /dev/video4. + +This example configures a pipeline to capture from the ADV7180 +video decoder, assuming PAL 720x576 input signals, with Motion +Compensated de-interlacing. The adv7180 must output sequential or +alternating fields (field type 'seq-tb' for PAL, or 'alternate'). +$outputfmt can be any format supported by the ipu1_ic_prpvf entity +at its output pad: .. code-block:: none @@ -529,11 +556,11 @@ entity at its output pad: media-ctl -l "'ipu1_ic_prp':2 -> 'ipu1_ic_prpvf':0[1]" media-ctl -l "'ipu1_ic_prpvf':1 -> 'ipu1_ic_prpvf capture':0[1]" # Configure pads - media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x480]" - media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480 field:interlaced]" - media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x480 field:interlaced]" - media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x480 field:none]" - media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x480 field:none]" + media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x576 field:seq-tb]" + media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x576]" + media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x576]" + media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x576 field:none]" + media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x576 field:none]" media-ctl -V "'ipu1_ic_prpvf':1 [fmt:$outputfmt field:none]" Streaming can then begin on the capture device node at