From patchwork Wed Jan 9 18:30:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754793 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 6C68C6C2 for ; Wed, 9 Jan 2019 18:30:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6123229319 for ; Wed, 9 Jan 2019 18:30:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54CC3292DB; Wed, 9 Jan 2019 18:30:30 +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 04DE3292CB for ; Wed, 9 Jan 2019 18:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfAISa3 (ORCPT ); Wed, 9 Jan 2019 13:30:29 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38041 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbfAISa3 (ORCPT ); Wed, 9 Jan 2019 13:30:29 -0500 Received: by mail-pl1-f195.google.com with SMTP id e5so3956767plb.5; Wed, 09 Jan 2019 10:30:28 -0800 (PST) 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=RmobXmdh5KaomT8TdFIr2+dJd6/NCDTEAkU6A7sJjko=; b=ONehKLSbVq+0fPChek5XsBf9lexIOo5/LOzDcjlbNrGC5gKyGIb5nSQc7Ka11PapqJ Ho5Bv3s4MAa+NrPNJHt0v6qsUvkpnHY1E55E68kyAbkJcZMB4r6PTRuKwNCNWns2Xt8g 4vKEDv0tlfHDnYDSEO8WioYkfpJFwcH6ywgdiKeFHsLMJYBA73JQ3W11CRHLW1dpwWe9 mS0kC2ABs9Ug+V+TgSgYwWg9p8ktYI5J+qWEjQTiR/+8LCcbceXoYqAFXDH0rgp7vCCk hpGiPBVz/0r3uZcy5SwEsiAlDB4Vsd+jOoSTGx2VLhw5MU9QufbrsfkCJeITGIaT4C3T p/2Q== 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=RmobXmdh5KaomT8TdFIr2+dJd6/NCDTEAkU6A7sJjko=; b=UZujKcAN0BFYMJMJgnK4rbW3ge3HQ9stmoRuedeFveVBbfbwIyJi/Ep8m/oNxrHBE4 UEy7ieM9cv0z7Hd75+nirs4f0F5smOXbQAbNqV4nFFilHpxcJj2aflGXkWntb+EjG2Kb TQIVUM6KNgp04apfBL9coz2yP6t5AhIZvCaZxrTRfyl3PS75Wq1ClYJ1Eupk693xg6zd 2luWPv7XdcMXCvA7QF1tg7WfN2DSYZSVeS43nRTnZFkG+1kuhR3Erz6RTfyzEs/GSKtn 4X9oabcRmiITUEBmm9c5IMbqLtDfl2rpBHRpZbFqkCrnONkRDhwh7IYM3dYCWj9scLUw R/Ng== X-Gm-Message-State: AJcUukeWT+ZbXMmPkukWoKT01+X4EC5alcs9dgjuRhmoRV0nVPkeRI9R rOIQZscYGkNEnKDkfR2PUzQI4swV X-Google-Smtp-Source: ALg8bN42d5PKBPw20PX6QXXbXuHl4fFs5OOdA9gKZ9Y3c18/A0E87cL/c1t5VdAMY58IOUOM5+zhVA== X-Received: by 2002:a17:902:e18d:: with SMTP id cd13mr7157567plb.262.1547058627810; Wed, 09 Jan 2019 10:30:27 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:27 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 01/11] media: videodev2.h: Add more field helper macros Date: Wed, 9 Jan 2019 10:30:04 -0800 Message-Id: <20190109183014.20466-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 v3: - none 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 d6eed479c3a6..bca07d35ea09 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 Jan 9 18:30:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754815 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 F38EE6C2 for ; Wed, 9 Jan 2019 18:31:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3E2E292A1 for ; Wed, 9 Jan 2019 18:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E00A3293D1; Wed, 9 Jan 2019 18:31:55 +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 16429293F7 for ; Wed, 9 Jan 2019 18:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbfAISac (ORCPT ); Wed, 9 Jan 2019 13:30:32 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43204 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727410AbfAISab (ORCPT ); Wed, 9 Jan 2019 13:30:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id gn14so3949689plb.10; Wed, 09 Jan 2019 10:30:30 -0800 (PST) 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=l/3WrQEthwtj4GAviq8IarF6y36hy857OcIsk573qcA=; b=XbxNq1w7SYXxozjnsPFyIUGCcLMvu1IhyxZWAujDt1pAecMRdUWDPls47XKDAEvG5/ 4OaUWvFiE+g7LW3YDct3DFf0md8xbTs6YY6Jez+wYDjyuvyI3ijWB7MQB1f+bAKuwsCt hjzFqnq1o6KQQJgHa5IXwR2ixgYCZh9ZbfAoNa5i8lzTJbsWl96s8FIc38Y1eS3CG/oG OJvSCLHxIqTgnq/paDZWY1UMaiJXSo/MW+xrQr6rmjZ+ha/CVSCfwkxGyWM1nSAmJu3e ivgv0BpWYxRCt45H7Z55mR1qt+v2EJ8WVzbAe1YexRuwHcZgr4HTXb4L0ZElQ6Vc3RKR CMLA== 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=l/3WrQEthwtj4GAviq8IarF6y36hy857OcIsk573qcA=; b=UuI0Vp7VLeAMsnChprqB4RcdJYeAoWnFFzpB7sLMcnzOqoGVn+LSYrVqHIS0ck5P1e NgRlBoaX/qdVAzptYKPvxs4d12IpLNMpuB/DLTRyEcefRW49k4nNcVJqohCD2NRF4/rS NEhnKw+uoLYxbGQPO+oNVM93MB+Y6U/A+RGy4rZJf0a53hJMITC/85mjgFiZIqQJR9kN FE5EmpttPHrUi+d/d1K2PdiaQ0pg9UDXLCMUxMb1KCc6vXy8Q77eTl9i/1x7cfQGbvHU TSa8fxtxx7qvwMfIaH8fgxaanB+HZVqTr71vL+kLfhw8C9qg3A4lAB+eNZXjIPLeYcWd JZNg== X-Gm-Message-State: AJcUukfjhHqrAk/bGA+15KovbL6ANwXJY0q1/qK//NdjT5A9FX1Is00k xZO3990jbycwqebZkTPeIxSjWBqt X-Google-Smtp-Source: ALg8bN5cpUJCKsC6Dvp7aE6nw2TvmfaDLrj/sY3KHGkafbM6V4wokBg9YxC3US0hKJcQnBJUeXNogg== X-Received: by 2002:a17:902:a6:: with SMTP id a35mr7119428pla.201.1547058629596; Wed, 09 Jan 2019 10:30:29 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:28 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , 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 v8 02/11] gpu: ipu-csi: Swap fields according to input/output field types Date: Wed, 9 Jan 2019 10:30:05 -0800 Message-Id: <20190109183014.20466-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel Acked-by: Philipp Zabel --- Changes since v5: - Convert to const the infmt, outfmt, and mbus_cfg pointer args to ipu_csi_init_interface(), suggested by Philipp Zabel. - Bring back if_fmt local var and don't copy outfmt to local stack in csi_setup(), suggested by Philipp. Changes since v4: - Cleaned up some convoluted code in ipu_csi_init_interface(), suggested by Philipp. - Fixed a regression in csi_setup(), caught by Philipp. --- drivers/gpu/ipu-v3/ipu-csi.c | 126 +++++++++++++++------- drivers/staging/media/imx/imx-media-csi.c | 7 +- include/video/imx-ipu-v3.h | 5 +- 3 files changed, 89 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index aa0e30a2ba18..d1e575571a8d 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -325,12 +325,21 @@ 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. */ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, - struct v4l2_mbus_config *mbus_cfg, - struct v4l2_mbus_framefmt *mbus_fmt) + const struct v4l2_mbus_config *mbus_cfg, + const struct v4l2_mbus_framefmt *mbus_fmt) { int ret; @@ -374,22 +383,76 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, return 0; } +static int +ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi, + const struct v4l2_mbus_framefmt *infmt, + const 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) + const struct v4l2_mbus_config *mbus_cfg, + const struct v4l2_mbus_framefmt *infmt, + const 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; - ret = fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + ret = fill_csi_bus_cfg(&cfg, mbus_cfg, infmt); if (ret < 0) return ret; /* 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 | @@ -416,42 +479,22 @@ 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); + if (width == 720 && height == 480) { + std = V4L2_STD_NTSC; + height = 525; + } else if (width == 720 && height == 576) { + std = V4L2_STD_PAL; + height = 625; } else { dev_err(csi->ipu->dev, - "Unsupported 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; break; case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: @@ -476,9 +519,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 4223f8d418ae..c2a8d9cd31b7 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -679,12 +679,7 @@ 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; /* @@ -702,7 +697,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, &if_fmt, 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 e582e8e7527a..bbc8481f567d 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -354,8 +354,9 @@ 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); + const struct v4l2_mbus_config *mbus_cfg, + const struct v4l2_mbus_framefmt *infmt, + const 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 Jan 9 18:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754811 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 63B6E14DE for ; Wed, 9 Jan 2019 18:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59402293D7 for ; Wed, 9 Jan 2019 18:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DA92293A7; Wed, 9 Jan 2019 18:31:54 +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 C77A629416 for ; Wed, 9 Jan 2019 18:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727454AbfAISad (ORCPT ); Wed, 9 Jan 2019 13:30:33 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34754 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727422AbfAISac (ORCPT ); Wed, 9 Jan 2019 13:30:32 -0500 Received: by mail-pg1-f193.google.com with SMTP id j10so3678666pga.1; Wed, 09 Jan 2019 10:30:32 -0800 (PST) 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=4N7ojczW0kjHmDJMWNYmDjBpUir6wWRrzDKNFy4GszY=; b=I7ej+k+dFMuBnjZYmBkcISKCwv0/tA9IA/cIcx7zCrMr7gRrCeVvfeTd8x3mCp3mqe mS8nfKn0j3CcgPQPL+mfAD2JUb3s7wsdC35xvQbGLDTPJUN/dcL9SI8/FfzXZKkGXxU5 TjQ1kteZJD6cIBUpBkv+b4QmtyFSJkDSo8DnfHT2c0mH8Juj5J6Dc6afkWc4AY1exlWB tCeHCaHSH5ecSZOHMKPceaBNcu7EB6vZ/hokxUN7OiV7FdeCIQxEgpSQHfgj81ig9VtD N7I3uFqig9zV0pnxjZ/+BeVEKfVirJScg6IGGMjh7mCGptfNtKg7NhtsdtTVwcyplFt6 RBdw== 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=4N7ojczW0kjHmDJMWNYmDjBpUir6wWRrzDKNFy4GszY=; b=CWD6VIFFFJcLbcxLZOdLCVb5vXxeA7sLaRgXO5M/oFLoY4TLZZT67jZLy2CUNOB7qb s0mXDlyKjC/6HQNHIgsywVP81NRuhzu0Ep2WW0DdXaRogQV78yFlaDZ4kYIjb9mGZO05 0VH2vlFVUiv4abArkhl9qj1DOI6+QcYBZ5aeDcXFp96FUc/XM+9elnWvWGAu1NtGB/63 CsphGIya2/DsqpDRL1UsPjIls/59Uy1KtVeCBFXUAbErQS5tfFCZ2e7h3FRrIOpis4DX 4yITRGyfAby3K2uR8G102B7wg+Kj9oyG8+k9qvwSPa7NqpOO5Mn+C88dhBMzfUFyKE6W QASw== X-Gm-Message-State: AJcUukdYKXg7Cw6qb/di+AxTIQEvJoJoEiwtdytgw59jLMKJq2XRrDHh zofKnTvgaIpRJkeoeInyA0aetFA/ X-Google-Smtp-Source: ALg8bN7g2lzEOGzHo4p7WEN6PrnndcZEIDpUQje3h4y70I0aNXlhxaFYzrXspUp1/yDVsTEKcXKHIw== X-Received: by 2002:a62:2702:: with SMTP id n2mr7196147pfn.29.1547058631145; Wed, 09 Jan 2019 10:30:31 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:30 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , 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 v8 03/11] gpu: ipu-v3: Add planar support to interlaced scan Date: Wed, 9 Jan 2019 10:30:06 -0800 Message-Id: <20190109183014.20466-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel Acked-by: Philipp Zabel --- 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 163fadb8a33a..d047a6867c59 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c @@ -277,9 +277,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; @@ -290,9 +291,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 28f41caba05d..af7224846bd5 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 c2a8d9cd31b7..da4808348845 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -512,7 +512,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 bbc8481f567d..c887f4bee5f8 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -258,7 +258,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 Jan 9 18:30:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754795 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 DD86614DE for ; Wed, 9 Jan 2019 18:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2476292DB for ; Wed, 9 Jan 2019 18:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D09BA29351; Wed, 9 Jan 2019 18:30:36 +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 01FC1292DB for ; Wed, 9 Jan 2019 18:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727488AbfAISae (ORCPT ); Wed, 9 Jan 2019 13:30:34 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38048 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727441AbfAISae (ORCPT ); Wed, 9 Jan 2019 13:30:34 -0500 Received: by mail-pl1-f196.google.com with SMTP id e5so3956876plb.5; Wed, 09 Jan 2019 10:30:33 -0800 (PST) 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=4LfVC7K9jhQHp0MEPczGn12glxH+9AGZnYjQefJqoZo=; b=kq+Ko1TmhE6gBwT5jj8V9z+tsZXZxXHhNmdQJHlG1ZA2wHnqVYrLauCAHmax1Sp91O 5UbvwZVqEeFG+4mh3J3T6ug/2swYGnxovNacdaUhr+lbGc2q3U7FjRUAeoE90ugKagCK NuCYzTJkjyQ6sKipVatZDa5F197u7C4uyaIWmK60FffJgIwR4ufsfIW3BFumjkTwxijZ ZSW0uN3piQ8VzcVpU6VTxx+k0P6b+UFE/2SsB+vvj/ipIKcthotJ4bxfrHvxSKdP46mV z08i+Qy++7I8AabeAtWyB5LxG0DcklJtqtNDyrtmj7phX7DyslSXaHwJwU7WiAy5kR27 NSmw== 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=4LfVC7K9jhQHp0MEPczGn12glxH+9AGZnYjQefJqoZo=; b=jA0fwBxleXanAdUw3EtX7oZne3Qw3aeKVrqdQX5gFnNrxMI8BS5BHiYwcMVFvGq/5f BcnSYakoEFdFom8Mof7O8qV820ah1zYLFOIkGQOf28Wwc4VxGDaOZfZvoO1GzZeqF/DW bZ3h1moQVJr0hAr1cLJX7Ons6DtVjCFj2npFLlNsHXyVMnjcBu3AX+zphd7GhtYjPAR7 W7VAaFQdyKoH6QsKGjc2ElQdN6YYtgaKiP9ujJcTUNiy/yCAr3I8DnwWlVnHeKSKYbUW wat9vxlAvdSVPIwYWfGn0ieba8g/dHZM3vRf63kx94GBZL8kxhIxu+cmO0nczqeKsbKg cXaA== X-Gm-Message-State: AJcUukfhu+GUQx8ss5Y6FoXMlUql9qZDGd11lUOzOZ1TYH/bzCeGqaVf lJf+MyHiWR6wYIPRCEXC74hKGBjL X-Google-Smtp-Source: ALg8bN4fre5YvMkslOTjIla7RY/qEu4wgNJJoM1SHgF0dyeHQAKohTotYmJlQJ6xmvkiAgR1NajdPg== X-Received: by 2002:a17:902:8541:: with SMTP id d1mr7214072plo.205.1547058632696; Wed, 09 Jan 2019 10:30:32 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:32 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 04/11] media: imx: Fix field negotiation Date: Wed, 9 Jan 2019 10:30:07 -0800 Message-Id: <20190109183014.20466-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel --- 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 af7224846bd5..1a03d4c9d7b8 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 b37e1186eb2f..01ec9443de55 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 da4808348845..e3a4f39dbf73 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -398,16 +398,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); @@ -424,6 +426,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: @@ -509,8 +519,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); @@ -1304,6 +1313,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, @@ -1343,25 +1384,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, @@ -1389,6 +1419,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 Jan 9 18:30:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754809 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 3DA246C2 for ; Wed, 9 Jan 2019 18:31:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C2E293C0 for ; Wed, 9 Jan 2019 18:31:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25352293F0; Wed, 9 Jan 2019 18:31:47 +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 A6161293D1 for ; Wed, 9 Jan 2019 18:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbfAISb0 (ORCPT ); Wed, 9 Jan 2019 13:31:26 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38724 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727497AbfAISaf (ORCPT ); Wed, 9 Jan 2019 13:30:35 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so3667949pgc.5; Wed, 09 Jan 2019 10:30:35 -0800 (PST) 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=SvPBX07XjgOGjqAl4kODKrCpf2pdSaymIbWsAOXzlto=; b=KDIFoWUONF4BlbZrrGTI5ZwLmaqWunmSYo+8LTdW2elyu2fQ4zJK2OvADyaDfceoac V2iRzonNtLof4HvxvqS7ljYEcJjOIhCJvX8uOo8z8QqQWg7My3Qszeo7S5JL25cQMXoI a2g+yc1KGjvGdSl5+q/Fkm7kJJQ4bS3+PtX0BKMz8qFIJeCODcUN7Fiwf5w//MNOCexC ecnmiONuX9a7HMSBbE9KdRZfFIDVUQfcxJUisgdaZqX9Yvre7ZZOj1bEfM6UXELAwe02 8X+YHA4uzxIVY22B1QySb5m9IwmiRJ10XUNNvQLUE2w7lwUuUxNepnlQ86mtZFcRCtxG titw== 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=SvPBX07XjgOGjqAl4kODKrCpf2pdSaymIbWsAOXzlto=; b=MFcSzLWNKl6OHmZMdYc0C5P3cbQv6GDfN/kQp0xonRjT2vUfygQAzJ5kwTwwccX+lZ kcTtfuamBKrIYlM//TJJ8LPKT+3V0xTRjQpQI7/8uLNVeh4ePxh1XtJmrnUqJ6iSXxNX Hrn7CYnK3J9X+xFwYsDLaTIhOaq4dLt1Rjfrcx5ILwqZosCO+DPjRnwDiV4zfXBNGbua 7pqRkl/n3KtEtrpBbJHiR/CD9QgCOpq3335GczpVommUD332o0GrqBgOWsI6baZvQVrt XOygin5s0Gt8+qKPO6DzxtX4WXK2cv3O3gu+LlCY/uFMGvftBkEWS73vcDqUxgYVUxUY IfAw== X-Gm-Message-State: AJcUukfEaiupL0X2wbPzOz92mPPcuVlmKhaSEGsAehedaFpR2yb4qnoo +PDhb4XxTi92Z31+Bd5IlrlKyO01 X-Google-Smtp-Source: ALg8bN5m9CbaoKVOSx8jAYQ8UwTNDz7BMjGiAIY6sZbLCqFkuIwSbO4HxeMcpApYddvMsahQpJm/ew== X-Received: by 2002:a62:2f06:: with SMTP id v6mr7131370pfv.216.1547058634466; Wed, 09 Jan 2019 10:30:34 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:33 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 05/11] media: imx-csi: Double crop height for alternate fields at sink Date: Wed, 9 Jan 2019 10:30:08 -0800 Message-Id: <20190109183014.20466-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel --- 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 e3a4f39dbf73..10945cbdbd71 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1142,6 +1142,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; @@ -1149,6 +1151,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 @@ -1158,12 +1164,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; } } @@ -1403,6 +1409,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; @@ -1530,6 +1538,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 Jan 9 18:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754807 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 B70716C2 for ; Wed, 9 Jan 2019 18:31:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACD82293BB for ; Wed, 9 Jan 2019 18:31:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0B3C293C0; Wed, 9 Jan 2019 18:31:22 +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 4575E293A3 for ; Wed, 9 Jan 2019 18:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727540AbfAISah (ORCPT ); Wed, 9 Jan 2019 13:30:37 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41804 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbfAISah (ORCPT ); Wed, 9 Jan 2019 13:30:37 -0500 Received: by mail-pf1-f195.google.com with SMTP id b7so4044219pfi.8; Wed, 09 Jan 2019 10:30:36 -0800 (PST) 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=VLRlyyf684+Sy+VEdPL3zWCq7VMbjh74HM7d3CHGuyk=; b=Ln0vlqgBmAye0sWe7KkDpi4O2nR8gU3r+bjvxxiGbsrry7JvwJU4yYf1VZf5gx8Vjc T0x7pT7DjeN2FXcU3qcpC39/xSnWT1LXPUUDpq4fsvOAHtsvg41eVqxUT0a4eUN+ysDT RkZu4pTIcvN3ZUhAng/xbBv7G1pKKNzMzLHqAILqTbbHXDREXYS2Ps1RpaVjMdT+xq1s jgkhX12yn3Sqa0L2vjLXuKoqHMUE/yIEKFmwh3UIpbd4eHb/As6nIFSSWMLfsHE9K5r3 2mHCCCQKX5vnUqNSjoaSc0gfJBzUA3lYmE07lA8PuPg0OidBmyoOA0V8YaAxblBNh8U/ K/VA== 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=VLRlyyf684+Sy+VEdPL3zWCq7VMbjh74HM7d3CHGuyk=; b=t2aIl7OOgPbIQntfMUXa6CHqBbQ0ZcUX4c4hLK83/BjL4aqy73LK2EExF2Yrg9U7F7 1CDYX8fc9YincDZVQ6ipspbQfXS4y5dd2rqSPzS05mTzhTZQX4uK2vEI1xlk6eRs6baS vRaLcoHH3otgrz7bwLzf1c9/hUH/90dW2/l1bEgwCVRoAFEPyxMf2roiMx2zn1qXyyNa xL3iLiU39LjsFlRhlndI1iYk0jcsJ+J19h14ZUvv2HEiCTh5bLeHe2mZzDXmGCUeMol5 yB5Pm++NaOXF0WJDfNnXKH2VTVi9pt3LXINMqK8x/53a8owZtSFL8HpT8e9OVFgRZdaG vhdQ== X-Gm-Message-State: AJcUukcrm/vTZBfakP+paWCmM0l3B56p2siL30EXnLsZ40u1RzBl0PaS arXcrPgS4b626MXaA2nF3pLBim7m X-Google-Smtp-Source: ALg8bN5QI2x3wMNhqcrigoZbWemdDTgcKsFrAcECYj25M3VxSh3N6xZn1wXqILMFEIg70OFr38AV2g== X-Received: by 2002:a63:6c48:: with SMTP id h69mr6143222pgc.139.1547058636032; Wed, 09 Jan 2019 10:30:36 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:35 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 06/11] media: imx: interweave and odd-chroma-row skip are incompatible Date: Wed, 9 Jan 2019 10:30:09 -0800 Message-Id: <20190109183014.20466-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel --- 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 1a03d4c9d7b8..cf76b0432371 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 10945cbdbd71..604d0bd24389 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -457,8 +457,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 Jan 9 18:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754805 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 48B4814DE for ; Wed, 9 Jan 2019 18:31:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA2F293BB for ; Wed, 9 Jan 2019 18:31:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30B8D293C6; Wed, 9 Jan 2019 18:31:21 +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 DA020293C0 for ; Wed, 9 Jan 2019 18:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727728AbfAISbP (ORCPT ); Wed, 9 Jan 2019 13:31:15 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33218 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727547AbfAISai (ORCPT ); Wed, 9 Jan 2019 13:30:38 -0500 Received: by mail-pf1-f195.google.com with SMTP id c123so4066674pfb.0; Wed, 09 Jan 2019 10:30:38 -0800 (PST) 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=rYSzVI0OvbJN9zcjKQFFiU9YJ6PIbqf35eYJ6lEUQGw=; b=auXlhuq4rQjZNkZHouAQkfBqVell+CghUl7ty0wBfLDvc4bdXyDARCxEvJnWBf83rS PNyfzRyoap5QF1vSGJ7l/PYER2OXORl/SVquk0XSYuTsNQYwyVB7IjrTTzmUnBJr+9g4 Cfu61B62dHm/RktWA+eJIRX5MnzG4eycqeN0mwlD8FigQ/3STCQmeD+g6cR2MJg0bk4g UI2lOCdNHeB6KqTGq+98GOHAywzu40QATPiQdRfcQJy4H23uTHPDIdo9EK3RI8nih5G8 UJaXK1Pud7vbRD0yT5EKNqEvsAY4g5d9VhQcxk4+Z/INiS1QT1pCmVxw8NU5wtTb3o1Z r+Gw== 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=rYSzVI0OvbJN9zcjKQFFiU9YJ6PIbqf35eYJ6lEUQGw=; b=nLMi3tJ9HY48gy4xPpYHAD0699l/bLqzDisT6Naq0e+IISt1RANgAgD6h9HBDIQooq bolyfV6gA7GcfoBKRihNUVv7jOk7tbkbZ5rIq9ZPltBHaQz8SUelaPbGn9CnhCbS1RR/ syOJILUnxtGpjetxrXkTgwnckZmDEHb40Fq2PgF6ESmJHXVdKnF1YvjUFKaRH0u6rYh5 OtKN3yS7qKVCfQsI0Nf3uCOawoU3+gJxxjLL9wfIBlekmBXXWlertUV4JqmK9Z0rXCx1 WYjiDQmUkH9WcX0AVmOSFClh7tC9aGDYmu1+Oc2XwZWa3JOpXif1bI4tp+TLaDjzkCAb evNA== X-Gm-Message-State: AJcUukdVQW9rZqpxEtpyNmSDKWZ3sMkAuy8sl+GaScf/CzBnUzar4TC/ vXzXqy/VSRwTc/mMnOOou0d03jk7 X-Google-Smtp-Source: ALg8bN6/bZnmmgVWUn7QxH+rUz8ioNd8j9GyyFlnpimjGj88d9Fi+ev+I61r1/UTvGxxAvy8ashMcQ== X-Received: by 2002:a63:ee0e:: with SMTP id e14mr6297493pgi.8.1547058637386; Wed, 09 Jan 2019 10:30:37 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:36 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 07/11] media: imx-csi: Allow skipping odd chroma rows for YVU420 Date: Wed, 9 Jan 2019 10:30:10 -0800 Message-Id: <20190109183014.20466-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 604d0bd24389..6f1e11b8a7cb 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -452,6 +452,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 Jan 9 18:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754803 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 D6F5B6C2 for ; Wed, 9 Jan 2019 18:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCC5C293B1 for ; Wed, 9 Jan 2019 18:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAF00293C6; Wed, 9 Jan 2019 18:31:14 +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 66B50293BB for ; Wed, 9 Jan 2019 18:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727577AbfAISam (ORCPT ); Wed, 9 Jan 2019 13:30:42 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42997 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727564AbfAISaj (ORCPT ); Wed, 9 Jan 2019 13:30:39 -0500 Received: by mail-pg1-f195.google.com with SMTP id d72so3658345pga.9; Wed, 09 Jan 2019 10:30:39 -0800 (PST) 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=BwIrt/QiZthUXo9qim2CsYJxYbNHfbi5cRl8NpsI+xE=; b=emG336981TFdCUY7y0qoK45HeEv+pXU9lwS5N/BoNJGeYwDPZ42S31fu+s/ryOLg4N gU47Xonr5TjvkRfpC2H3uy3kF+ASHOFZVnwBXqDXz51QhxN0AqTDY7iiHlM1KfS08a2j uWUOFr3EiDXP1irH/JYtkUfoTGQkbLQ9bvZ7LpIT+M1ticqIUemgIU6C3YWwcCluwN1R CxGaipfZp0Qt0LefXqx9xpLKkPgagsXV7Lpp3njHFTsxonkheJmSXMawy3X0dwDzW4NG b2RiW9kXqMCVMSWp4iAt06bqpkRGwS2zjQCPnUFXFKA//eP/IOiACNW5zMUl26aSCNh0 gYTQ== 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=BwIrt/QiZthUXo9qim2CsYJxYbNHfbi5cRl8NpsI+xE=; b=dbhKAPZCAoHOBgnkSZ6874t/glTdYvTX8WZiIU1Sn00NjElNyP/tJn6KTVyhfGJOQR uXG9ojQQJef3DOfy17kiAYOrnukTMNyDqOm02t6HAJ5RmhESHKm+1jrbJilVFDsxZPwC WLzbYLQh2UUDQHHJN+om3EdpEnOX47PBbqzZNVfibua6GZxsBycaHBbNS7/AbssFA7wY Cc7H4OrpWpgNWq5/zG4kKE4VEhXMFh1t4m0Mm+9CqMlvoGymWyZ5KRgQe/1XHvYptIef ZNwIdnZ9U5xWN7edlzbedYM5lye/0ddaFwy2uKmUUy2KwreD5HdfvvnKAvRSk1F4LhWN vxZA== X-Gm-Message-State: AJcUukevbpUUw7yOvN28pxC3H7jqV6+kEyGhYikCD7Y+0GeyRD/3p6u0 p76AMebFzdGH6xexLrNzQkC12mZh X-Google-Smtp-Source: ALg8bN5vW8U5T1LzIGmQ7sPihf9u/sASnFuuodK/PKZyOufH/bedmrYRaB8/hMLjYxho6+kuOmPGwQ== X-Received: by 2002:aa7:87ce:: with SMTP id i14mr7024922pfo.20.1547058638765; Wed, 09 Jan 2019 10:30:38 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:38 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 08/11] media: imx: vdic: rely on VDIC for correct field order Date: Wed, 9 Jan 2019 10:30:11 -0800 Message-Id: <20190109183014.20466-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 482250d47e7c..4a890714193e 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 Jan 9 18:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754797 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 9B0EB6C2 for ; Wed, 9 Jan 2019 18:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90F2F292A1 for ; Wed, 9 Jan 2019 18:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 855AF29352; Wed, 9 Jan 2019 18:30: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 26DC3292BA for ; Wed, 9 Jan 2019 18:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727585AbfAISan (ORCPT ); Wed, 9 Jan 2019 13:30:43 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42997 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726906AbfAISal (ORCPT ); Wed, 9 Jan 2019 13:30:41 -0500 Received: by mail-pg1-f193.google.com with SMTP id d72so3658376pga.9; Wed, 09 Jan 2019 10:30:40 -0800 (PST) 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=Gcttxf1Z7z55ZyajsIidmjFu/+A5UNPbDLAEbT+eqcI=; b=WGtqIi5677wxvJBBlWB+mpYP5kk5raN2DbE9alnTtwCYdqkfRbJ9fuV9ahtXA9jzUG tCIYLEX7PbCxOya5CrW5taIQ1HVrvbceLd2EI1EXZl/0lhxYlgeg8oF/WRsP8rrdb/EY 6iMbwy7lgAh3EO/ld3Y4G293Du1jCuQgvgSqvhFx/UGCmVeI5d3xfstqmf2/cz4GRHo8 fdVUp+/duIDy8ZpE2J1bnP7sAxXpG8anof9xXzJVNzS5ZQbS8y59EOGn3O1/kJ6oCTvI 2LIb9w0lZrMUkqYMy0B6qRvIrFIq5BSN74RXg2FSFncOwG5ow+AI8Gttv+JQGHJdtblo 5a6A== 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=Gcttxf1Z7z55ZyajsIidmjFu/+A5UNPbDLAEbT+eqcI=; b=bfli4GnM0HfHmCvB+i/sFnNwcWGg0GkQn3sCJt6dQHKWAEnhBWUZ68GSEMgxQIEW4a 9LPGhqPLo3sJXXUcIsXuRHjoRJlu1K95M4vPtftZRxkwecxbo6aMDE85PdZ+2Vjsyw// YmFj2FmOCnpumIZIgpikonc4Xi/2exVhcDkzgEtRP9pxI/YijLNlzPaRCwhT0H9I7agS Gorc1uTrGxEu3xNmr8mNKWkUA4L1PEgMMmy8Hued6CVXV4uyGhbH4jyQA8ljylZJknht v+ASk5x6tkBeGtJECNjHLyACgQRuF7cGq6AqcGmAlWkfgxwi5tnY0m1K3Mzkh8ZO1tA4 o9+Q== X-Gm-Message-State: AJcUukchxJLH1xGC3q9p9UK3+cKtHwzShaUf+Dfagup3gtrkqmMlMaqV Ucuzo0j+mu3+Q4qIwL/dQ3LLcUmk X-Google-Smtp-Source: ALg8bN6FdJYp14emiXzv59a12NJnQLiojI3h4MpsS1VJwaaxq6sEwxw8GJkCcpcqKukNRx0SngHJPg== X-Received: by 2002:a63:5207:: with SMTP id g7mr6484873pgb.253.1547058640199; Wed, 09 Jan 2019 10:30:40 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:39 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 09/11] media: imx-csi: Move crop/compose reset after filling default mbus fields Date: Wed, 9 Jan 2019 10:30:12 -0800 Message-Id: <20190109183014.20466-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel --- 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 6f1e11b8a7cb..8537ecb7dd17 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1409,19 +1409,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) { @@ -1437,6 +1424,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 Jan 9 18:30:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754801 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 2BF6B14DE for ; Wed, 9 Jan 2019 18:31:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 207B6292B1 for ; Wed, 9 Jan 2019 18:31:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1510C293C1; Wed, 9 Jan 2019 18:31:04 +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 68D07292B1 for ; Wed, 9 Jan 2019 18:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbfAISa5 (ORCPT ); Wed, 9 Jan 2019 13:30:57 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39344 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727597AbfAISao (ORCPT ); Wed, 9 Jan 2019 13:30:44 -0500 Received: by mail-pg1-f195.google.com with SMTP id w6so3667003pgl.6; Wed, 09 Jan 2019 10:30:42 -0800 (PST) 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=MgVGGz7c/1eQCk6GVcYZNBejHDRAkH26qTrPS59NoKo=; b=vNYGpn8AzWSs036n2IvtThpIHlhRLGQEp3gIeDKHTMXEuBLevUwa2fJRIGI8Qs0alR Q5mnO2fQml6hHeotwmIs6P4ggrCI9FkLwNEqMUh59OMqZSJFUusp9Q6ywpObZGXFyLY6 N8Dk3B4xsCOh2H0KQlunHm/QJtonNoL1XUA6HM229Ldk951rO9hW55ddXlokObud2Wyc AlPMAGGE+C5F4QQ9rsy8Epu37W7pq2IHjLn0cLXSh4dBDjBXsdxxixFA6qKtFynYvbVJ dUaHhI9Ezhf0VRFtg+0JccYwQj2GWctqwE3WP4wg1lLxLN9kmlUAcTcnIj8wMhaMKMoj mdkQ== 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=MgVGGz7c/1eQCk6GVcYZNBejHDRAkH26qTrPS59NoKo=; b=gcWWcFQSLk+reb/ufCNydMwP/ckz5Ty7sSRARjkkcaiBYV4iaGbYdUhhZZh02JMR76 +4xSDZrKFD9fq+1of94aclAce1nrXPItsDFE9j8+lhxk2bITRsi8pkIaML2vXz7JLi1o JwpiALIuQ32HGmf240aZcC2ppajJttapE+QjcxGInsr6W+UuAJL3Zt6hOjNFhCrt2aB9 tC58M1vSnffuDHCcd2K40736KRLKXmZA2RRHxwbNe0NnOmtBDKR9RPS1br3813NGQjMF 43z2QBLxJ/V8RF82Yw4SbbqSmtatADFtKnwbh3yQs8ZV/oeOLfrY0MjGzjy0Oilk3wd+ QP9g== X-Gm-Message-State: AJcUukdv44xEuUES4/XGJc1M4M/KL1DEriSECizi/fRO/O2c0Hb7OUhG zkl06A73ME23uNcUPE472TI8W5Kc X-Google-Smtp-Source: ALg8bN7o6wa+0ti7Qie0POvIUFSKUiWUTfDKygaVMy2qQn8LE9ud/TFPHFyjTC5mS8gWtuoQPa/53Q== X-Received: by 2002:a62:dbc2:: with SMTP id f185mr6962243pfg.235.1547058641578; Wed, 09 Jan 2019 10:30:41 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:40 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: 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 v8 10/11] media: imx: Allow interweave with top/bottom lines swapped Date: Wed, 9 Jan 2019 10:30:13 -0800 Message-Id: <20190109183014.20466-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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 Reviewed-by: Philipp Zabel --- Changes since v4: - Removed interweave_offset and replace with boolean interweave_swap, suggested by Philipp Zabel. --- drivers/staging/media/imx/imx-ic-prpencvf.c | 25 +++++++++---- drivers/staging/media/imx/imx-media-csi.c | 40 ++++++++++++++++++--- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index cf76b0432371..33ada6612fee 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -106,6 +106,7 @@ 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 */ + bool interweave_swap; /* swap top/bottom lines when interweaving */ struct completion last_eof_comp; }; @@ -235,6 +236,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 (priv->interweave_swap && ch == priv->out_ch) + phys += vdev->fmt.fmt.pix.bytesperline; + ipu_cpmem_set_buffer(ch, priv->ipu_buf_num, phys); } @@ -376,8 +380,9 @@ static int prp_setup_channel(struct prp_priv *priv, * the IDMAC output channel. */ interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && - V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) && - channel == priv->out_ch; + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + priv->interweave_swap = interweave && + image.pix.field == V4L2_FIELD_INTERLACED_BT; if (rot_swap_width_height) { swap(image.pix.width, image.pix.height); @@ -388,6 +393,11 @@ static int prp_setup_channel(struct prp_priv *priv, (image.pix.width * outcc->bpp) >> 3; } + if (priv->interweave_swap && channel == priv->out_ch) { + /* start interweave scan at 1st top line (2nd line) */ + image.rect.top = 1; + } + image.phys0 = addr0; image.phys1 = addr1; @@ -396,8 +406,8 @@ static int prp_setup_channel(struct prp_priv *priv, * 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)) { + if ((channel == priv->out_ch && !interweave) || + channel == priv->rot_out_ch) { switch (image.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: @@ -424,8 +434,11 @@ static int prp_setup_channel(struct prp_priv *priv, if (rot_mode) ipu_cpmem_set_rotation(channel, rot_mode); - if (interweave) - ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, + if (interweave && channel == priv->out_ch) + ipu_cpmem_interlaced_scan(channel, + priv->interweave_swap ? + -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 8537ecb7dd17..555aa45e02e3 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -114,6 +114,7 @@ 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 */ + bool interweave_swap; /* swap top/bottom lines when interweaving */ struct completion last_eof_comp; }; @@ -286,6 +287,9 @@ 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); + if (priv->interweave_swap) + phys += vdev->fmt.fmt.pix.bytesperline; + ipu_cpmem_set_buffer(priv->idmac_ch, priv->ipu_buf_num, phys); } @@ -433,6 +437,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); + priv->interweave_swap = interweave && + image.pix.field == V4L2_FIELD_INTERLACED_BT; switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: @@ -486,6 +492,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) } if (passthrough) { + if (priv->interweave_swap) { + /* start interweave scan at 1st top line (2nd line) */ + image.phys0 += image.pix.bytesperline; + image.phys1 += image.pix.bytesperline; + } + ipu_cpmem_set_resolution(priv->idmac_ch, image.rect.width * passthrough_cycles, image.rect.height); @@ -495,6 +507,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ipu_cpmem_set_format_passthrough(priv->idmac_ch, passthrough_bits); } else { + if (priv->interweave_swap) { + /* start interweave scan at 1st top line (2nd line) */ + image.rect.top = 1; + } + ret = ipu_cpmem_set_image(priv->idmac_ch, &image); if (ret) goto unsetup_vb2; @@ -526,6 +543,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) if (interweave) ipu_cpmem_interlaced_scan(priv->idmac_ch, + priv->interweave_swap ? + -image.pix.bytesperline : image.pix.bytesperline, image.pix.pixelformat); @@ -1338,16 +1357,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 Jan 9 18:30:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10754799 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 153AD14DE for ; Wed, 9 Jan 2019 18:30:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0996F292B1 for ; Wed, 9 Jan 2019 18:30:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F10C2293AF; Wed, 9 Jan 2019 18:30:55 +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 0FEE5293BB for ; Wed, 9 Jan 2019 18:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727631AbfAISap (ORCPT ); Wed, 9 Jan 2019 13:30:45 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38734 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727608AbfAISao (ORCPT ); Wed, 9 Jan 2019 13:30:44 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so3668124pgc.5; Wed, 09 Jan 2019 10:30:44 -0800 (PST) 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=NiubgfHwtmHyldU4HehS7kmldJEMB2GDEFzDkJLxVyQ=; b=B46kbOL9KxzYMm9ECra0EtZCubL540/naMDKXrYxsyU5stYgfyvuFZN7vzKIn3x0M0 FwyLoRiX19/+AynIdcXUIWYLhz2/ysBLnDbuhfIyAp8hn26JU84kW40vnE0YA5PNyQfu CKHDwUciH/Vrl1E767Uyq9Lnmw9liP3CgFfiwzXG9YugoDxXtuQj9cJvYUI3l0Vd8lw3 73YD/VAtX2uhvyqXzGXu+Irr77BJriJ2cnqL7HJR1zF2geOc3Yqi+9aemNxf7S9nseVt cLBRGG7za9s1fyuJhENtCHk9CmkRttpmabADvg4/ywBihuBKDaRbGxbAaNHgo+ImNT5J 87Cw== 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=NiubgfHwtmHyldU4HehS7kmldJEMB2GDEFzDkJLxVyQ=; b=s9mEt+MMbeRiGBy7o8LnkfOgxxkhjJUxmbi7GUacccj1f19uJYIwIjv+UajCCTht0s 3iARG7IhuKiDdsr2IhTDgyDKGKpFHa1IY8KJ1aM2AuF5jnCTH58nB7y4Bu8iHkMahaO2 Q1yvBGF/VCggjK8oYtPrEyGuQ2sVBu7cq0Lpxe7KhfdxxodEKjqBUMaeKRgZtJLWJXKz DKjfNXlnM7j0uVppqlabrKSrcMOD5+waJskotptW599Z5gUEq6sAKWaTny0ShyJRZpS+ EYKEaUWgAsuwH8ydRCpe50o6en+fNJBRBRzLb6qGvGIubCMbbUyUMaakIKXgJ/wW0U6u Dzhg== X-Gm-Message-State: AJcUukf/UX0a4ex4r35hZn9QYgF/DH5lE3vFiqO7Z0x1OLDQlsUDOUqH NXYwiEj+pOXN4efnSR9wyccYmeoY X-Google-Smtp-Source: ALg8bN6vNMTad8ncJXrXQ5EmmfzBRa3yRXYMCgvM7t80M5LidphJpzsB/hLjUxqso42K72lIUQQAFg== X-Received: by 2002:a65:41c2:: with SMTP id b2mr6388921pgq.67.1547058643366; Wed, 09 Jan 2019 10:30:43 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id v191sm157551056pgb.77.2019.01.09.10.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 10:30:42 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 11/11] media: imx.rst: Update doc to reflect fixes to interlaced capture Date: Wed, 9 Jan 2019 10:30:14 -0800 Message-Id: <20190109183014.20466-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190109183014.20466-1-slongerbeam@gmail.com> References: <20190109183014.20466-1-slongerbeam@gmail.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. Cleanup some language in various places in the process. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel Acked-by: Tim Harvey Tested-by: Tim Harvey --- Changes since v4: - Make clear that it is IDMAC channel that does pixel reordering and interweave, not the CSI. Caught by Philipp Zabel. Changes since v3: - none. 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 | 103 +++++++++++++++--------- 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/Documentation/media/v4l-drivers/imx.rst b/Documentation/media/v4l-drivers/imx.rst index 6922dde4a82b..9314af00d067 100644 --- a/Documentation/media/v4l-drivers/imx.rst +++ b/Documentation/media/v4l-drivers/imx.rst @@ -24,8 +24,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 @@ -175,15 +175,21 @@ 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 -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. +Note that since the IDMAC source pad makes use of an IDMAC channel, +pixel reordering within the same colorspace can be carried out by the +IDMAC channel. For example, if the CSI sink pad is receiving in UYVY +order, the capture device linked to the IDMAC source pad can capture +in YUYV order. Also, if the CSI sink pad is receiving a packed YUV +format, the capture device can capture a planar YUV format such as +YUV420. + +The IDMAC channel at the IDMAC source pad also supports simple +interweave without motion compensation, which is activated if the source +pad's field type is sequential top-bottom or bottom-top, and the +requested capture interface field type is set to interlaced (t-b, b-t, +or unqualified interlaced). The capture interface will enforce the same +field order as the source pad field order (interlaced-bt if source pad +is seq-bt, interlaced-tb if source pad is seq-tb). This subdev can generate the following event when enabling the second IDMAC source pad: @@ -325,14 +331,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. @@ -345,8 +351,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 @@ -369,8 +375,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 also supports simple +de-interlace without motion compensation, and pixel reordering. ipuX_ic_prpvf ------------- @@ -380,18 +386,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 supports 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 ----------------- @@ -516,10 +522,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 @@ -531,11 +560,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